Skip to content

Commit

Permalink
find and open conflict files from root git directory
Browse files Browse the repository at this point in the history
  • Loading branch information
olshevskiy87 committed Jan 28, 2018
1 parent 8f11fd7 commit 8684e49
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions conflict/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,16 @@ Run below command to change to a compatible conflict style

func Find() (err error) {
cwd, _ := os.Getwd()
stdout, stderr, _ := RunCommand("git", cwd, "--no-pager", "diff", "--check")

stdout, stderr, _ := RunCommand("git", cwd, "rev-parse", "--show-toplevel")
if len(stderr) != 0 {
return errors.New(stderr)
} else if len(stdout) == 0 {
return errors.New("no git top-level path")
}
topLevelPath := string(strings.Split(stdout, "\n")[0])

stdout, stderr, _ = RunCommand("git", cwd, "--no-pager", "diff", "--check")

if len(stderr) != 0 {
return errors.New(stderr)
Expand All @@ -172,7 +181,7 @@ func Find() (err error) {
}

for fname := range diffMap {
absPath := path.Join(cwd, fname)
absPath := path.Join(topLevelPath, fname)
if err = ReadFile(absPath); err != nil {
return
}
Expand Down

0 comments on commit 8684e49

Please sign in to comment.