From 181dc5d75e0a8844a095198b095dc56e609351cf Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 16 Nov 2017 00:03:35 -0500 Subject: editor: remove out of sync branch before checkout again If a branch was deleted from server, sometimes it is not reflected on local copy. Therefore, we need to remove the branch with same name if it is out of sync and then checkout to correct version. --- models/errors/repo.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'models/errors') diff --git a/models/errors/repo.go b/models/errors/repo.go index 15adb2b0..69c29be6 100644 --- a/models/errors/repo.go +++ b/models/errors/repo.go @@ -59,3 +59,16 @@ func IsMirrorNotExist(err error) bool { func (err MirrorNotExist) Error() string { return fmt.Sprintf("mirror does not exist [repo_id: %d]", err.RepoID) } + +type BranchAlreadyExists struct { + Name string +} + +func IsBranchAlreadyExists(err error) bool { + _, ok := err.(BranchAlreadyExists) + return ok +} + +func (err BranchAlreadyExists) Error() string { + return fmt.Sprintf("branch already exists [name: %s]", err.Name) +} -- cgit v1.2.3