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
|
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 {
|
err = filepath.Walk(repoPath, func(path string, info os.FileInfo, err error) error {
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
@ -115,6 +118,20 @@ func pull(url, repoPath string) ([]string, error) {
|
|||||||
return updatedFiles, nil
|
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 {
|
func (gc Config) Commit(repoPath, targetPath, message string) error {
|
||||||
commandArgs := generateGitArgs(repoPath)
|
commandArgs := generateGitArgs(repoPath)
|
||||||
addCmd := []string{"add", filepath.Join(repoPath, targetPath)}
|
addCmd := []string{"add", filepath.Join(repoPath, targetPath)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user