Skip to content

Commit

Permalink
Add RemoteExists to git client
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnstn committed Oct 11, 2023
1 parent 7ac9790 commit d875eda
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cli/pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Client interface {
Switch(...string) error
CommitAll(string, ...interface{}) error
Push() error
RemoteExists(string, string) bool
}

type client struct {
Expand Down Expand Up @@ -47,3 +48,9 @@ func (c *client) Push() error {
cmd := exec.Git(c.dir, c.verbose)
return cmd("push", "origin", "HEAD")
}

func (c *client) RemoteExists(remote, branch string) bool {
cmd := exec.Git(c.dir, c.verbose)
err := cmd("ls-remote", "--exit-code", "--heads", remote, branch)
return err == nil
}

0 comments on commit d875eda

Please sign in to comment.