Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var rootCmd = &cobra.Command{
by dynamically mounting them using a git-volume.yaml manifest.

"Keep code in Git, mount environments as volumes."`,
SilenceErrors: true,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
6 changes: 3 additions & 3 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var (
dryRun bool
syncDryRun bool
relativeLinks bool
)

Expand All @@ -34,14 +34,14 @@ it looks for it in the main Git worktree (inheritance).`,
}

return gv.Sync(gitvolume.SyncOptions{
DryRun: dryRun,
DryRun: syncDryRun,
RelativeLinks: relativeLinks,
})
},
}

func init() {
rootCmd.AddCommand(syncCmd)
syncCmd.Flags().BoolVar(&dryRun, "dry-run", false, "show what would be done without making changes")
syncCmd.Flags().BoolVar(&syncDryRun, "dry-run", false, "show what would be done without making changes")
syncCmd.Flags().BoolVar(&relativeLinks, "relative", false, "create relative symlinks instead of absolute")
}
7 changes: 5 additions & 2 deletions cmd/unsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"github.com/spf13/cobra"
)

// unsyncDryRun is the local flag for the unsync command
var unsyncDryRun bool

// unsyncCmd represents the unsync command
var unsyncCmd = &cobra.Command{
Use: "unsync",
Expand All @@ -29,12 +32,12 @@ to the source before deleting. If changed, it skips deletion to prevent data los
}

return gv.Unsync(gitvolume.UnsyncOptions{
DryRun: dryRun,
DryRun: unsyncDryRun,
})
},
}

func init() {
rootCmd.AddCommand(unsyncCmd)
unsyncCmd.Flags().BoolVar(&dryRun, "dry-run", false, "show what would be done without making changes")
unsyncCmd.Flags().BoolVar(&unsyncDryRun, "dry-run", false, "show what would be done without making changes")
}
Binary file removed gv
Binary file not shown.
62 changes: 62 additions & 0 deletions test/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,68 @@ fi
# Clean up for next tests
rm -rf copied_dir

# -----------------------------------------------------------------------------
# Test: Error Visibility (Bad Flag)
# -----------------------------------------------------------------------------
log "TEST" "Testing Error Visibility (Bad Flag)..."

# Capture stdout and stderr
if OUTPUT=$("$GV_BIN" sync --unknown-flag 2>&1); then
fail "Command should have failed but succeeded"
else
# Command failed as expected, check output for error message
if grep -q "unknown flag: --unknown-flag" <<< "$OUTPUT"; then
pass "Error message visible on stderr/stdout"
else
fail "Error message NOT found in output"
echo "Output: $OUTPUT"
fi
fi

# -----------------------------------------------------------------------------
# Test: Sync Dry Run Isolation
# -----------------------------------------------------------------------------
log "TEST" "Testing Sync Dry Run..."

# Set up a volume to sync
echo "DATA" > source.txt
cat > git-volume.yaml <<EOF
volumes:
- mount: "source.txt:target.txt"
mode: copy
EOF
git add git-volume.yaml >/dev/null 2>&1
git commit -m "init" >/dev/null 2>&1

# Run sync with dry-run
"$GV_BIN" sync --dry-run >/dev/null

if [[ ! -f "target.txt" ]]; then
pass "sync --dry-run did not create file"
else
fail "sync --dry-run CREATED file (meant to be dry run)"
fi

# -----------------------------------------------------------------------------
# Test: Unsync Dry Run Isolation
# -----------------------------------------------------------------------------
log "TEST" "Testing Unsync Dry Run..."

# Actually sync first
"$GV_BIN" sync >/dev/null
if [[ ! -f "target.txt" ]]; then
fail "Setup failed: sync did not create file"
fi

# Run unsync with dry-run
"$GV_BIN" unsync --dry-run >/dev/null

if [[ -f "target.txt" ]]; then
pass "unsync --dry-run did not remove file"
else
fail "unsync --dry-run REMOVED file (meant to be dry run)"
fi

# -----------------------------------------------------------------------------
# Summary
# -----------------------------------------------------------------------------
Expand Down