diff --git a/repository/factory.go b/repository/factory.go index 982f5f8..45ce01b 100644 --- a/repository/factory.go +++ b/repository/factory.go @@ -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) } diff --git a/repository/git.go b/repository/git.go index 0cc199f..414e27c 100644 --- a/repository/git.go +++ b/repository/git.go @@ -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() } diff --git a/repository/subversion.go b/repository/subversion.go index a6d40dc..b0b423d 100644 --- a/repository/subversion.go +++ b/repository/subversion.go @@ -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