mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-11 05:09:31 +01:00
Set IsBare true if migrated repo is empty.
Executes `git log -1` and sets IsBare to true if stderr contains this string: fatal: bad default revision 'HEAD'
This commit is contained in:
parent
00767a0522
commit
ae1650824c
1 changed files with 6 additions and 0 deletions
|
@ -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 a new issue