mirror of
https://github.com/rocky-linux/srpmproc.git
synced 2024-12-04 18:36:26 +00:00
Only import latest version of each stream/release by default
This commit is contained in:
parent
b18468ed62
commit
aa600cd524
@ -71,13 +71,24 @@ func (g *GitMode) RetrieveSource(pd *data.ProcessData) *data.ModeData {
|
||||
|
||||
var branches remoteTargetSlice
|
||||
|
||||
latestTags := map[string]*remoteTarget{}
|
||||
|
||||
tagAdd := func(tag *object.Tag) error {
|
||||
if strings.HasPrefix(tag.Name, fmt.Sprintf("imports/%s%d", pd.ImportBranchPrefix, pd.Version)) {
|
||||
log.Printf("tag: %s", tag.Name)
|
||||
branches = append(branches, remoteTarget{
|
||||
remote: fmt.Sprintf("refs/tags/%s", tag.Name),
|
||||
when: tag.Tagger.When,
|
||||
})
|
||||
refSpec := fmt.Sprintf("refs/tags/%s", tag.Name)
|
||||
if tagImportRegex.MatchString(refSpec) {
|
||||
match := tagImportRegex.FindStringSubmatch(refSpec)
|
||||
|
||||
exists := latestTags[match[2]]
|
||||
if exists != nil && exists.when.After(tag.Tagger.When) {
|
||||
return nil
|
||||
}
|
||||
|
||||
latestTags[match[2]] = &remoteTarget{
|
||||
remote: refSpec,
|
||||
when: tag.Tagger.When,
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -88,7 +99,7 @@ func (g *GitMode) RetrieveSource(pd *data.ProcessData) *data.ModeData {
|
||||
}
|
||||
_ = tagIter.ForEach(tagAdd)
|
||||
|
||||
if len(branches) == 0 {
|
||||
if len(latestTags) == 0 {
|
||||
list, err := remote.List(&git.ListOptions{})
|
||||
if err != nil {
|
||||
log.Fatalf("could not list upstream: %v", err)
|
||||
@ -110,6 +121,11 @@ func (g *GitMode) RetrieveSource(pd *data.ProcessData) *data.ModeData {
|
||||
}
|
||||
}
|
||||
|
||||
for _, branch := range latestTags {
|
||||
log.Printf("tag: %s", strings.TrimPrefix(branch.remote, "refs/tags/"))
|
||||
branches = append(branches, *branch)
|
||||
}
|
||||
|
||||
sort.Sort(branches)
|
||||
|
||||
var sortedBranches []string
|
||||
|
Loading…
Reference in New Issue
Block a user