@@ -289,7 +289,7 @@ func (d DiggerController) GithubSetupExchangeCode(c *gin.Context) {
289289 })
290290}
291291
292- func createOrGetDiggerRepoForGithubRepo (ghRepoFullName string , ghRepoOrganisation string , ghRepoName string , ghRepoUrl string , installationId int64 ) (* models.Repo , * models.Organisation , error ) {
292+ func createOrGetDiggerRepoForGithubRepo (ghRepoFullName string , ghRepoOrganisation string , ghRepoName string , ghRepoUrl string , installationId int64 , appId int64 , defaultBranch string , cloneUrl string ) (* models.Repo , * models.Organisation , error ) {
293293 slog .Info ("Creating or getting Digger repo for GitHub repo" ,
294294 slog .Group ("githubRepo" ,
295295 slog .String ("fullName" , ghRepoFullName ),
@@ -331,6 +331,10 @@ func createOrGetDiggerRepoForGithubRepo(ghRepoFullName string, ghRepoOrganisatio
331331 if r .RowsAffected > 0 {
332332 slog .Info ("Digger repo already exists, restoring if deleted" , "diggerRepoName" , diggerRepoName , "repoId" , existingRepo .ID )
333333 existingRepo .DeletedAt = gorm.DeletedAt {}
334+ existingRepo .GithubAppId = appId
335+ existingRepo .GithubAppInstallationId = installationId
336+ existingRepo .CloneUrl = cloneUrl
337+ existingRepo .DefaultBranch = defaultBranch
334338 models .DB .GormDB .Save (& existingRepo )
335339 return & existingRepo , org , nil
336340 }
@@ -339,7 +343,7 @@ func createOrGetDiggerRepoForGithubRepo(ghRepoFullName string, ghRepoOrganisatio
339343 repo , err := models .DB .CreateRepo (diggerRepoName , ghRepoFullName , ghRepoOrganisation , ghRepoName , ghRepoUrl , org , `
340344generate_projects:
341345 include: "."
342- ` )
346+ ` , installationId , appId , defaultBranch , cloneUrl )
343347 if err != nil {
344348 slog .Error ("Error creating Digger repo" , "diggerRepoName" , diggerRepoName , "error" , err )
345349 return nil , nil , err
@@ -2548,7 +2552,10 @@ func (d DiggerController) GithubAppCallbackPage(c *gin.Context) {
25482552 return
25492553 }
25502554
2551- _ , _ , err = createOrGetDiggerRepoForGithubRepo (repoFullName , repoOwner , repoName , repoUrl , installationId64 )
2555+ cloneUrl := * repo .CloneURL
2556+ defaultBranch := * repo .DefaultBranch
2557+
2558+ _ , _ , err = createOrGetDiggerRepoForGithubRepo (repoFullName , repoOwner , repoName , repoUrl , installationId64 , * installation .AppID , defaultBranch , cloneUrl )
25522559 if err != nil {
25532560 slog .Error ("Error creating or getting Digger repo" ,
25542561 "repoFullName" , repoFullName ,
0 commit comments