mirror of
https://gitee.com/gitea/gitea.git
synced 2024-12-26 15:52:57 +08:00
Merge pull request #1589 from siadat/migrating-empty-repository
Set IsBare true if migrated repo is empty
This commit is contained in:
commit
d504ee0417
@ -470,6 +470,12 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str
|
|||||||
return repo, fmt.Errorf("create update hook: %v", err)
|
return repo, fmt.Errorf("create update hook: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if repository is empty.
|
||||||
|
_, stderr, err = com.ExecCmdDir(repoPath, "git", "log", "-1")
|
||||||
|
if err != nil && strings.Contains(stderr, "fatal: bad default revision 'HEAD'") {
|
||||||
|
repo.IsBare = true
|
||||||
|
}
|
||||||
|
|
||||||
// Check if repository has master branch, if so set it to default branch.
|
// Check if repository has master branch, if so set it to default branch.
|
||||||
gitRepo, err := git.OpenRepository(repoPath)
|
gitRepo, err := git.OpenRepository(repoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user