Skip to content

Commit

Permalink
Bugfixes for application repository loaders processor
Browse files Browse the repository at this point in the history
  • Loading branch information
Icikowski committed Apr 28, 2022
1 parent 8529475 commit 249695c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions application/repos/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func (l *GitHubRepositoryLoader) LoadRepository(source string) (types.Repository
re := regexp.MustCompile(`^(?P<user>[^/]+)/(?P<repo>[^@/]+)(@(?P<branch>[^/]+))?/(?P<filename>.+)$`)
matches := re.FindStringSubmatch(source)

if len(matches) == 0 {
common.PrintErrorWhileMsg("parsing source", source, fmt.Errorf("invalid format"))
return repository, false
}

user := matches[re.SubexpIndex("user")]
repo := matches[re.SubexpIndex("repo")]
branch := matches[re.SubexpIndex("branch")]
Expand Down Expand Up @@ -53,6 +58,11 @@ func (l *GitHubRepositoryLoader) LoadRepository(source string) (types.Repository
return repository, false
}

default_branch := out["default_branch"]
if default_branch == nil {
common.PrintErrorWhileMsg("detecting default branch of", fmt.Sprintf("%s/%s", user, repo), fmt.Errorf("repository (probably) does not exist"))
return repository, false
}
branch = out["default_branch"].(string)
} else {
branch = l.config.DefaultBranchName
Expand Down

0 comments on commit 249695c

Please sign in to comment.