Skip to content

Commit

Permalink
Merge pull request #28 from thandayuthapani/master
Browse files Browse the repository at this point in the history
Fix Load Owners Function
  • Loading branch information
Jun Du authored May 3, 2019
2 parents de1e6ca + 6b37caf commit 4c4506f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions handlers/repository/gitclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ func (r *GitClient) CloneRepo() error {
return nil
}

func (r *GitClient) GetLocalRepoDir() string{
return r.LocalRepoDir
}

// RemoveMirror removes tmp local mirror dir
func (r *GitClient) RemoveMirror() error {
// remove local mirror dir
Expand Down Expand Up @@ -154,12 +158,14 @@ func (r *GitClient) RemoveRepo() error {
}

// CheckOut runs the command: git checkout
func (r *GitClient) CheckOut(branch string) error {
func (r *GitClient) CheckOut(branch string, localDir string) error {
glog.Infof("Checkout: %s", branch)
bs, err := exec.Command("git", "checkout", branch).CombinedOutput()
bs:= exec.Command("git", "checkout", branch)
bs.Dir = localDir
output, err := bs.CombinedOutput()
if err != nil {
// git checkout error
glog.Errorf("Failed to git checkout %s: %v", string(bs), err)
glog.Errorf("Failed to git checkout %s: %v", string(output), err)
return err
}
return err
Expand Down
2 changes: 1 addition & 1 deletion handlers/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (o *Repository) LoadOwners(branch string) error {
}

// checkout branch
err = o.GitClient.CheckOut(branch)
err = o.GitClient.CheckOut(branch, o.GitClient.LocalRepoDir)
if err != nil {
glog.Errorf("Failed to checkout %s", branch)
return nil
Expand Down

0 comments on commit 4c4506f

Please sign in to comment.