Open merge dialog instantly from pushed merge facts
This commit is contained in:
+3
-40
@@ -109,14 +109,6 @@ func RemoveWorktree(repo, path, branch string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
type Unmerged struct {
|
||||
Commits int
|
||||
Files int
|
||||
Insertions int
|
||||
Deletions int
|
||||
Uncommitted int
|
||||
}
|
||||
|
||||
type ConflictError struct {
|
||||
Files []string
|
||||
}
|
||||
@@ -125,41 +117,12 @@ func (e *ConflictError) Error() string {
|
||||
return "merge conflicts in " + strings.Join(e.Files, ", ")
|
||||
}
|
||||
|
||||
func UnmergedChanges(worktree, target string) (Unmerged, error) {
|
||||
u := Unmerged{}
|
||||
|
||||
func Ahead(worktree, target string) (int, error) {
|
||||
count, err := run(worktree, "rev-list", "--count", target+"..HEAD")
|
||||
if err != nil {
|
||||
return u, err
|
||||
return 0, err
|
||||
}
|
||||
u.Commits, err = strconv.Atoi(count)
|
||||
if err != nil {
|
||||
return u, err
|
||||
}
|
||||
|
||||
status, err := run(worktree, "status", "--porcelain", "--untracked-files=all")
|
||||
if err != nil {
|
||||
return u, err
|
||||
}
|
||||
if status != "" {
|
||||
u.Uncommitted = len(strings.Split(status, "\n"))
|
||||
}
|
||||
|
||||
tree, err := Snapshot(worktree)
|
||||
if err != nil {
|
||||
return u, err
|
||||
}
|
||||
changes, err := Compare(worktree, target, "HEAD", tree, "")
|
||||
if err != nil {
|
||||
return u, err
|
||||
}
|
||||
u.Files = len(changes.Files)
|
||||
for _, file := range changes.Files {
|
||||
u.Insertions += file.Additions
|
||||
u.Deletions += file.Deletions
|
||||
}
|
||||
|
||||
return u, nil
|
||||
return strconv.Atoi(count)
|
||||
}
|
||||
|
||||
func Behind(worktree, target string) (int, error) {
|
||||
|
||||
Reference in New Issue
Block a user