Skip to content

Commit ae7f008

Browse files
committed
feat(push): Add UI support for push branch
Add UI support for push branch Signed-off-by: mritd <[email protected]>
1 parent a43dd02 commit ae7f008

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

apps.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ func pushApp() *cli.App {
120120
if c.NArg() != 0 {
121121
return cli.ShowAppHelp(c)
122122
}
123-
return push()
123+
124+
m := newResultModel()
125+
m.message, m.err = push()
126+
127+
return tea.NewProgram(&m).Start()
124128
},
125129
}
126130
}

git_wapper.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,27 @@ func currentBranch() (string, error) {
4343
var buf bytes.Buffer
4444
err := gitCommand(&buf, "symbolic-ref", "--short", "HEAD")
4545
if err != nil {
46-
return "", err
46+
return "", errors.New(strings.TrimSpace(buf.String()))
4747
}
4848
return strings.TrimSpace(buf.String()), nil
4949
}
5050

51-
func push() error {
51+
func push() (string, error) {
5252
err := repoCheck()
5353
if err != nil {
54-
return fmt.Errorf("the current directory is not a git repository")
54+
return "", err
5555
}
5656

5757
branch, err := currentBranch()
5858
if err != nil {
59-
return err
59+
return "", err
6060
}
61-
return gitCommand(os.Stdout, "push", "origin", branch)
61+
var buf bytes.Buffer
62+
err = gitCommand(&buf, "push", "origin", branch)
63+
if err != nil {
64+
return "", errors.New(strings.TrimSpace(buf.String()))
65+
}
66+
return strings.TrimSpace(buf.String()), nil
6267
}
6368

6469
func commitMessageCheck(f string) error {

0 commit comments

Comments
 (0)