Skip to content

Commit

Permalink
Remove a FIXME
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Jun 24, 2024
1 parent 6162d89 commit c3fd723
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
3 changes: 1 addition & 2 deletions internal/git/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ func Changes(cmd CommandRunner, baseBranch string, filter PathFilter) ([]*FileCh
continue
}

// ignore directories
// FIXME move all files instead?
// This should never really happen since git doesn't track directories, only files.
if isDir, _ := isDirectoryPath(dstPath); isDir {
slog.Debug("Skipping directory entry change", slog.String("path", dstPath))
continue
Expand Down
57 changes: 57 additions & 0 deletions internal/git/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,63 @@ func TestChanges(t *testing.T) {
},
err: "",
},
{
title: "directory_renamed",
setup: func(t *testing.T) git.CommandRunner {
mustRun(t, "init", "--initial-branch=main", ".")
require.NoError(t, os.Mkdir("dir1", 0o755))
require.NoError(t, os.Mkdir("dir1/rules", 0o755))
require.NoError(t, os.WriteFile("dir1/rules/file1.txt", []byte("a1\na2\na3\n"), 0o644))
require.NoError(t, os.WriteFile("dir1/rules/file2.txt", []byte("b1\nb2"), 0o644))
mustRun(t, "add", "dir1")
gitCommit(t, "init")

mustRun(t, "checkout", "-b", "v1")
mustRun(t, "mv", "dir1", "dir2")
gitCommit(t, "rename")

return debugGitRun(t)
},
changes: []*git.FileChange{
{
Commits: []string{"1"},
Path: git.PathDiff{
Before: git.Path{
Name: "dir1/rules/file1.txt",
Type: git.File,
},
After: git.Path{
Name: "dir2/rules/file1.txt",
Type: git.File,
},
},
Body: git.BodyDiff{
Before: []byte("a1\na2\na3\n"),
After: []byte("a1\na2\na3\n"),
ModifiedLines: []int{1, 2, 3},
},
},
{
Commits: []string{"1"},
Path: git.PathDiff{
Before: git.Path{
Name: "dir1/rules/file2.txt",
Type: git.File,
},
After: git.Path{
Name: "dir2/rules/file2.txt",
Type: git.File,
},
},
Body: git.BodyDiff{
Before: []byte("b1\nb2"),
After: []byte("b1\nb2"),
ModifiedLines: []int{1, 2},
},
},
},
err: "",
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit c3fd723

Please sign in to comment.