Skip to content
Merged
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion services/pull/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,12 @@ func getDiffTree(repoPath, baseBranch, headBranch string) (string, error) {
out := bytes.Buffer{}
scanner := bufio.NewScanner(strings.NewReader(list))
for scanner.Scan() {
fmt.Fprintf(&out, "/%s\n", scanner.Text())
filepath := scanner.Text()
if strings.HasPrefix(filepath, `"`) { // the filepath contains " or \.
filepath = strings.TrimPrefix(filepath, `"`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to deal with \.

$ git diff-tree a06e7ac9fdbed88f73736b876ab63dfb680037ef aad2c7e2d2e381951cbaad3be107742f0b8fc132
:100644 100644 f1e195345db6ee7433b331c3aa333b50d46088f3 5c1b14949828006ed75a3e8858957f86a2f7e2eb M      "hello\\one\\\\two"

The actual file name is helo\one\\two

And there's also other edge cases like "with\nnew\nlines" or "hello\ttabs".

Unless we want to print them that way, which could work.

filepath = strings.TrimSuffix(filepath, `"`)
}
fmt.Fprintf(&out, "/%s\n", filepath)
}
return out.String(), nil
}