Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Nov 21, 2024
1 parent b705252 commit 46bdb79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion repository/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func New(destDir string, remote *Remote, identities []api.Ref) (r SCM, err error
type SCM interface {
Validate() (err error)
Fetch() (err error)
Branch(name string) (err error)
Branch(ref string) (err error)
Commit(files []string, msg string) (err error)
Head() (commit string, err error)
}
Expand Down
8 changes: 4 additions & 4 deletions repository/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ func (r *Git) Fetch() (err error) {
}

// Branch creates a branch with the given name if not exist and switch to it.
func (r *Git) Branch(name string) (err error) {
func (r *Git) Branch(ref string) (err error) {
cmd := command.New("/usr/bin/git")
cmd.Dir = r.Path
cmd.Options.Add("checkout", name)
cmd.Options.Add("checkout", ref)
err = cmd.Run()
if err != nil {
cmd = command.New("/usr/bin/git")
cmd.Dir = r.Path
cmd.Options.Add("checkout", "-b", name)
cmd.Options.Add("checkout", "-b", ref)
}
r.Remote.Branch = name
r.Remote.Branch = ref
return cmd.Run()
}

Expand Down
9 changes: 5 additions & 4 deletions repository/subversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,19 @@ func (r *Subversion) Fetch() (err error) {
}

// Branch checks out a branch.
// The branch is created as needed. The Remote.URL will be set to the branchURL.
func (r *Subversion) Branch(branchURL string) (err error) {
// The branch is created as needed. The Remote.URL will be set to the ref.
// The `ref` must be a URL.
func (r *Subversion) Branch(ref string) (err error) {
branch := Subversion{
Authenticated: r.Authenticated,
Remote: r.Remote,
Path: r.Path,
}
_, err = urllib.Parse(branchURL)
_, err = urllib.Parse(ref)
if err != nil {
return
}
branch.Remote.URL = branchURL
branch.Remote.URL = ref
defer func() {
if err == nil {
r.Remote.URL = branch.Remote.URL
Expand Down

0 comments on commit 46bdb79

Please sign in to comment.