diff options
author | Mike JS. Choi <mkchoi212@icloud.com> | 2018-03-10 22:10:17 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-10 22:10:17 -0600 |
commit | fb868ea8b8683d0f1dc5376b1719b535b6c958a3 (patch) | |
tree | f06c1bfbbeab565e3190540bd564a4b6b850c2b0 | |
parent | c4d1d396fdbe9b8719d9f72bc5a2e501f2cafc9b (diff) | |
parent | 8684e49dd4c58da6cfb2d2996bc74dbefafc49aa (diff) |
Merge pull request #27 from olshevskiy87/t1
Find and open conflict files from root git directory
-rw-r--r-- | conflict/parse.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/conflict/parse.go b/conflict/parse.go index d83c04e..527aef6 100644 --- a/conflict/parse.go +++ b/conflict/parse.go @@ -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) @@ -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 } |