Skip to content

Commit

Permalink
refactor: improve the extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Nov 27, 2020
1 parent aa62d6b commit e930b89
Showing 1 changed file with 22 additions and 44 deletions.
66 changes: 22 additions & 44 deletions 2_extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,61 +79,39 @@ func Extract(g *client.GitClient, scope *parser.Scope) ([]*ExtractSplice, error)

commit := commits[index]

if tag := getTagOfCommit(scope.Tags, commit); tag != nil {
splice := &ExtractSplice{
Name: tag.Name,
Tag: tag,
Commit: make([]*object.Commit, 0),
}
splice.Commit = append(splice.Commit, commit)
index++
internalLoop:
for {
if index == len(commits) {
break internalLoop
}

nextCommit := commits[index]
item := &ExtractSplice{
Name: "Unreleased",
Commit: make([]*object.Commit, 0),
}

if t := getTagOfCommit(scope.Tags, nextCommit); t != nil {
break internalLoop
}
item.Commit = append(item.Commit, commit)

splice.Commit = append(splice.Commit, nextCommit)
if tag := getTagOfCommit(scope.Tags, commit); tag != nil {
item.Tag = tag
item.Name = tag.Name
}

index++
}
index++

splices = append(splices, splice)
} else {
item := &ExtractSplice{
Name: "Unreleased",
loop:
for {
if index == len(commits) {
break loop
}

internalLoop2:
for {
if index == len(commits) {
splices = append(splices, item)
break internalLoop2
}
nextCommit := commits[index]

nextCommit := commits[index]

if t := getTagOfCommit(scope.Tags, nextCommit); t != nil {
splices = append(splices, item)
break internalLoop2
}
if t := getTagOfCommit(scope.Tags, nextCommit); t != nil {
break loop
}

if item.Commit == nil {
item.Commit = make([]*object.Commit, 0)
}
item.Commit = append(item.Commit, nextCommit)

item.Commit = append(item.Commit, nextCommit)
index++
}

index++
}
splices = append(splices, item)

}
}

return splices, nil
Expand Down

0 comments on commit e930b89

Please sign in to comment.