fix(git): fetch all branches (#32)
This commit is contained in:
parent
9ad10fa73b
commit
e308afb79a
17
git/git.go
17
git/git.go
@ -46,6 +46,9 @@ func (gc Config) CloneOrPull(url, repoPath string) (map[string]struct{}, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := fetchAll(repoPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = filepath.Walk(repoPath, func(path string, info os.FileInfo, err error) error {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
@ -115,6 +118,20 @@ func pull(url, repoPath string) ([]string, error) {
|
||||
return updatedFiles, nil
|
||||
}
|
||||
|
||||
func fetchAll(repoPath string) error {
|
||||
commandArgs := generateGitArgs(repoPath)
|
||||
configCmd := []string{"config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"}
|
||||
if _, err := utils.Exec("git", append(commandArgs, configCmd...)); err != nil {
|
||||
return xerrors.Errorf("error in git config: %w", err)
|
||||
}
|
||||
|
||||
fetchCmd := []string{"fetch", "--all"}
|
||||
if _, err := utils.Exec("git", append(commandArgs, fetchCmd...)); err != nil {
|
||||
return xerrors.Errorf("error in git fetch: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gc Config) Commit(repoPath, targetPath, message string) error {
|
||||
commandArgs := generateGitArgs(repoPath)
|
||||
addCmd := []string{"add", filepath.Join(repoPath, targetPath)}
|
||||
|
Loading…
Reference in New Issue
Block a user