From 5d8ee85720b22d962d058119973a5dbe7ea5b33d Mon Sep 17 00:00:00 2001 From: poyo Date: Thu, 9 Jul 2026 22:42:14 +0200 Subject: [PATCH] fix repo creation failing to grab repo id --- db/repos.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/db/repos.go b/db/repos.go index 570a962..631b36c 100644 --- a/db/repos.go +++ b/db/repos.go @@ -23,21 +23,22 @@ func (db *DB) NewRepo(user *types.User, repo *types.Repo) (*git.Repository, erro return nil, errors.ErrRepoAlreadyExists // check if it already exists on a DB level. } - // create the actual git repo - git_repo, err := lib_git.InitRepo(user, &repo.ID) - if err != nil { - // cleanup - return nil, err - } - // create the record inside the db - err = db.Create(repo).Error + err := db.Create(repo).Error if err != nil { if strings.Contains(err.Error(), "UNIQUE constraint") { return nil, errors.ErrRepoAlreadyExists // shouldn't happen but handle gracefully, just in case. } return nil, err } + + // create the actual git repo + git_repo, err := lib_git.InitRepo(user, &repo.ID) + if err != nil { + // cleanup + db.Where(&repo).Delete(&repo) + return nil, err + } defer func() { _ = git_repo.Close() }() -- 2.54.0