resetToRemoteTrackingBranch resets to the commit pointed by the remote tracking branch. This is used to reset the local branch to the state of the remote branch so it is expected that the latest changes have been fetched. go-git wipes out git-ignored changes so must use the git command.
(repoDir, branch string)
| 395 | // This is used to reset the local branch to the state of the remote branch so it is expected that the latest changes have been fetched. |
| 396 | // go-git wipes out git-ignored changes so must use the git command. |
| 397 | func resetToRemoteTrackingBranch(repoDir, branch string) error { |
| 398 | _, err := gitutil.Run(context.Background(), repoDir, "reset", "--hard", "origin/"+branch) |
| 399 | if err != nil { |
| 400 | if strings.Contains(err.Error(), "unknown revision") { |
| 401 | return gitutil.ErrRefNotFound |
| 402 | } |
| 403 | return err |
| 404 | } |
| 405 | return nil |
| 406 | } |
| 407 | |
| 408 | // setGitConfig sets the git config key locally in the repo. |
| 409 | func setGitConfig(repoDir, key, value string) error { |
no test coverage detected