diff options
author | Unknwon <u@gogs.io> | 2017-02-16 06:28:37 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-16 06:28:37 -0500 |
commit | 88143f1934af6e2d1e2e4f260a9dc08f836437ca (patch) | |
tree | 5ffcc96fb7dd62da0d88359dd474c04dc599da4d | |
parent | 3137665e6eb2626e7f05b083ce14bbbcd78f41b3 (diff) |
models/repo: UpdateLocalCopy should always aceept valid branch name
-rw-r--r-- | gogs.go | 2 | ||||
-rw-r--r-- | models/repo.go | 16 | ||||
-rw-r--r-- | models/wiki.go | 4 | ||||
-rw-r--r-- | templates/.VERSION | 2 |
4 files changed, 14 insertions, 10 deletions
@@ -16,7 +16,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.9.149.0215" +const APP_VER = "0.9.150.0216" func init() { setting.AppVer = APP_VER diff --git a/models/repo.go b/models/repo.go index be46b797..a06e9751 100644 --- a/models/repo.go +++ b/models/repo.go @@ -469,11 +469,17 @@ func (repo *Repository) LocalCopyPath() string { } // UpdateLocalCopy fetches latest changes of given branch from repoPath to localPath. -// It creates a new clone if local copy does not exist. -// This function checks out target branch by default, it is safe to assume subsequent -// operations are operating against target branch when caller has confidence for no race condition. -func UpdateLocalCopyBranch(repoPath, localPath, branch string) (err error) { +// It creates a new clone if local copy does not exist, but does not checks out to a +// specific branch if the local copy belongs to a wiki. +// For existing local copy, it checks out to target branch by default, and safe to +// assume subsequent operations are against target branch when caller has confidence +// about no race condition. +func UpdateLocalCopyBranch(repoPath, localPath, branch string, isWiki bool) (err error) { if !com.IsExist(localPath) { + // Checkout to a specific branch fails when wiki is an empty repository. + if isWiki { + branch = "" + } if err = git.Clone(repoPath, localPath, git.CloneRepoOptions{ Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second, Branch: branch, @@ -502,7 +508,7 @@ func UpdateLocalCopyBranch(repoPath, localPath, branch string) (err error) { // UpdateLocalCopyBranch makes sure local copy of repository in given branch is up-to-date. func (repo *Repository) UpdateLocalCopyBranch(branch string) error { - return UpdateLocalCopyBranch(repo.RepoPath(), repo.LocalCopyPath(), branch) + return UpdateLocalCopyBranch(repo.RepoPath(), repo.LocalCopyPath(), branch, false) } // PatchPath returns corresponding patch file path of repository by given issue ID. diff --git a/models/wiki.go b/models/wiki.go index 4f754f80..20285e3d 100644 --- a/models/wiki.go +++ b/models/wiki.go @@ -76,9 +76,7 @@ func (repo *Repository) LocalWikiPath() string { // UpdateLocalWiki makes sure the local copy of repository wiki is up-to-date. func (repo *Repository) UpdateLocalWiki() error { - // Don't pass branch name here because it fails to clone and - // checkout to a specific branch when wiki is an empty repository. - return UpdateLocalCopyBranch(repo.WikiPath(), repo.LocalWikiPath(), "") + return UpdateLocalCopyBranch(repo.WikiPath(), repo.LocalWikiPath(), "master", true) } func discardLocalWikiChanges(localPath string) error { diff --git a/templates/.VERSION b/templates/.VERSION index b176a3f4..43de04d0 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.9.149.0215
\ No newline at end of file +0.9.150.0216
\ No newline at end of file |