Browse Source

Merge pull request #1829 from ethantkoenig/no_branches

Commitless repos should be bare
Andrey Nering 2 years ago
parent
commit
635273cea6
2 changed files with 5 additions and 1 deletions
  1. 1 1
      models/action.go
  2. 4 0
      modules/context/repo.go

+ 1 - 1
models/action.go

@@ -517,7 +517,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
517 517
 	}
518 518
 
519 519
 	// Change repository bare status and update last updated time.
520
-	repo.IsBare = false
520
+	repo.IsBare = repo.IsBare && opts.Commits.Len <= 0
521 521
 	if err = UpdateRepository(repo, false); err != nil {
522 522
 		return fmt.Errorf("UpdateRepository: %v", err)
523 523
 	}

+ 4 - 0
modules/context/repo.go

@@ -390,6 +390,10 @@ func RepoRef() macaron.Handler {
390 390
 				if err != nil {
391 391
 					ctx.Handle(500, "GetBranches", err)
392 392
 					return
393
+				} else if len(brs) == 0 {
394
+					err = fmt.Errorf("No branches in non-bare repository %s",
395
+						ctx.Repo.GitRepo.Path)
396
+					ctx.Handle(500, "GetBranches", err)
393 397
 				}
394 398
 				refName = brs[0]
395 399
 			}