Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to merge if file path contains " or \ #8629

Merged
merged 9 commits into from
Nov 1, 2019
Merged
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)
zeripath marked this conversation as resolved.
Show resolved Hide resolved
}
return out.String(), nil
}