___________ .___.__ __ ___________.__.__ \_ _____/ __| _/|__|/ |_ \_ _____/|__| | ____ | __)_ / __ | | \ __\ | __) | | | _/ __ \ | \/ /_/ | | || | | \ | | |_\ ___/ _______ /\____ | |__||__| \___ / |__|____/\___ > \/ \/
(localPath, branch string)
| 85 | // discardLocalRepoBranchChanges discards local commits/changes of |
| 86 | // given branch to make sure it is even to remote branch. |
| 87 | func discardLocalRepoBranchChanges(localPath, branch string) error { |
| 88 | if !com.IsExist(localPath) { |
| 89 | return nil |
| 90 | } |
| 91 | |
| 92 | // No need to check if nothing in the repository. |
| 93 | if !git.RepoHasBranch(localPath, branch) { |
| 94 | return nil |
| 95 | } |
| 96 | |
| 97 | rev := "origin/" + branch |
| 98 | if err := git.Reset(localPath, rev, git.ResetOptions{Hard: true}); err != nil { |
| 99 | return errors.Newf("reset [revision: %s]: %v", rev, err) |
| 100 | } |
| 101 | return nil |
| 102 | } |
| 103 | |
| 104 | func (r *Repository) DiscardLocalRepoBranchChanges(branch string) error { |
| 105 | return discardLocalRepoBranchChanges(r.LocalCopyPath(), branch) |
no outgoing calls
no test coverage detected