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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

- The picker now shows the newer copy's name and "last updated" phrase in bold in the highlighted row's comparison, so you can see at a glance which copy is the live one. Nothing is bold when the timestamps match or can't be read.

### Fixed

- On macOS, a gitignored folder that exists only on the destination is no longer offered for deletion.

## [1.3.0] - 2026-10-06

### Added
Expand Down
19 changes: 19 additions & 0 deletions acceptance_tests/honor-gitignore.feature
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ Feature: Leave ignored files out of a sync
| action | path |
| create | logs/README.md |

@remote
Scenario: An ignored folder only on the remote is not offered for deletion
# openrsync can name the deleted folder without its trailing slash, which a
# folder rule such as build/ does not match unless csync restores it.
Given a local git repository containing these files:
"""
src/main.go
"""
And the repository's ".gitignore" contains:
"""
build/
"""
And that 3 files have been added on the remote under "build"
And that the file "notes.txt" has been added locally
When I run "csync ./project user@host:/project"
Then the reported actions should be:
| action | path |
| create | notes.txt |

# ---------------------------------------------------------------------------
# TODO: sibling scenarios, each its own behavior — drafted as we drill in.
# ---------------------------------------------------------------------------
Expand Down
26 changes: 26 additions & 0 deletions internal/compare/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,35 @@ func parseActions(rsyncOut string) []Action {
seen[key] = true
actions = append(actions, action)
}
markDeletedFolders(actions)
return actions
}

// markDeletedFolders restores the trailing slash on a deleted folder reported
// without one, recognizing it by the deletions beneath it. openrsync was seen on
// macOS CI to drop the slash, and the slash is what tells git the path is a folder:
// without it a folder ignore rule such as build/ fails to match, and the ignored
// folder is offered for deletion. An empty folder has nothing beneath it to give it
// away, so it keeps the bare name.
func markDeletedFolders(actions []Action) {
folders := map[string]bool{}
for _, a := range actions {
if a.Verb != "delete" {
continue
}
for i := range len(a.Path) {
if a.Path[i] == '/' {
folders[a.Path[:i]] = true
}
}
}
for i, a := range actions {
if a.Verb == "delete" && folders[a.Path] {
actions[i].Path += "/"
}
}
}

// actionFromLine translates one --out-format record into an Action, reporting
// false for any line that is not one. A regular-file transfer in either direction —
// `>f...` (received into the destination: pull or local-to-local) and `<f...` (sent
Expand Down
27 changes: 27 additions & 0 deletions internal/compare/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,30 @@ func TestParseActions_OpenrsyncBareDeleteWithGlobMeta_IsDropped(t *testing.T) {
t.Errorf("got %+v, want no actions (dropped)", got)
}
}

// Behavior: openrsync can report a deleted folder without its trailing slash, as
// macOS CI showed. The deletions beneath it prove it is a folder, and the slash is
// restored so a folder ignore rule such as build/ still matches it.
func TestParseActions_BareDeletedFolder_RegainsTheTrailingSlash(t *testing.T) {
got := parseActions("*deleting build/a/x.log\n*deleting build/a\n*deleting build\n")

want := []Action{
{Verb: "delete", Path: "build/a/x.log"},
{Verb: "delete", Path: "build/a/"},
{Verb: "delete", Path: "build/"},
}
if !reflect.DeepEqual(got, want) {
t.Errorf("got %+v, want %+v", got, want)
}
}

// Behavior: only deletions count as evidence of a folder. A file being replaced by
// a folder of the same name is deleted while the folder's contents are created, and
// that file must keep its bare name.
func TestParseActions_DeletedFileUnderCreates_KeepsItsName(t *testing.T) {
got := parseActions("*deleting build\n" + line(">f+++++++++", 1, "build/x.log"))

if got[0].Path != "build" {
t.Errorf("got %q, want the deleted file to stay %q", got[0].Path, "build")
}
}
Loading