Skip to content

Commit

Permalink
Fix panic in case of empty repo or without remote origin
Browse files Browse the repository at this point in the history
  • Loading branch information
peti2001 committed Mar 26, 2021
1 parent 9bafa02 commit a00871b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (r *RepoExtractor) Extract() error {

err := r.initRepo()
if err != nil {
fmt.Println("Cannot init repo_info_extractor. Error: ", err.Error())
return err
}

Expand Down Expand Up @@ -122,7 +123,7 @@ func (r *RepoExtractor) initRepo() error {

out, err := cmd.CombinedOutput()
if err != nil {
return err
fmt.Println("Cannot get remote.origin.url. Use directory path to get repo name.")
}

repoName := ""
Expand Down Expand Up @@ -196,7 +197,11 @@ func (r *RepoExtractor) analyseCommits() error {
fmt.Println("Analysing commits")

var commits []*commit.Commit
userCommits := make([]*commit.Commit, 0, len(commits))
commits, err := r.getCommits()
if len(commits) == 0 {
return nil
}
if err != nil {
return err
}
Expand Down Expand Up @@ -249,7 +254,6 @@ func (r *RepoExtractor) analyseCommits() error {
}

// Only consider commits for user
userCommits := make([]*commit.Commit, 0, len(commits))
for _, v := range commits {
if _, ok := selectedEmails[v.AuthorEmail]; ok {
userCommits = append(userCommits, v)
Expand Down

0 comments on commit a00871b

Please sign in to comment.