change default branch to "main" and rollback faulty change

This commit is contained in:
Mustafa Gezen 2021-02-20 05:12:16 +01:00
parent 541f446a50
commit 0c150ed1f8
2 changed files with 23 additions and 5 deletions

View File

@ -204,7 +204,7 @@ func executePatchesRpm(pd *ProcessData, md *modeData) {
return
} else {
err = w.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewRemoteReferenceName("origin", "master"),
Branch: plumbing.NewRemoteReferenceName("origin", "main"),
Force: true,
})
// common patches found, apply them
@ -303,6 +303,9 @@ func patchModuleYaml(pd *ProcessData, md *modeData) {
pushBranch = strings.Replace(md.pushBranch, repString, newString, 1)
} else if strings.HasPrefix(rpm.Ref, "stream-") && len(split) == 2 {
pushBranch = md.pushBranch
} else if strings.HasPrefix(rpm.Ref, "stream-") && len(split) == 3 {
// example: ant
pushBranch = fmt.Sprintf("%s%d-stream-%s", pd.BranchPrefix, pd.Version, split[2])
} else if strings.HasPrefix(rpm.Ref, "stream-") {
pushBranch = fmt.Sprintf("%s%s-stream-%s", pd.BranchPrefix, string(split[3][0]), split[1])
} else if strings.HasPrefix(rpm.Ref, "rhel-") {

View File

@ -79,7 +79,7 @@ func ProcessRPM(pd *ProcessData) {
remotePrefix = "modules"
}
var pushedHashes []string
latestHashForBranch := map[string]string{}
// already uploaded blobs are skipped
var alreadyUploadedBlobs []string
@ -122,7 +122,6 @@ func ProcessRPM(pd *ProcessData) {
sourceWorktree := *md.worktree
for _, branch := range md.branches {
md.sourcesToIgnore = []*ignoredSource{}
md.repo = &sourceRepo
md.worktree = &sourceWorktree
md.tagBranch = branch
@ -130,6 +129,10 @@ func ProcessRPM(pd *ProcessData) {
source.expired = true
}
if strings.Contains(md.tagBranch, "-beta") {
continue
}
rpmFile := md.rpmFile
// create new repo for final dist
repo, err := git.Init(memory.NewStorage(), memfs.New())
@ -292,6 +295,18 @@ func ProcessRPM(pd *ProcessData) {
status, _ := w.Status()
log.Printf("successfully processed:\n%s", status)
statusLines := strings.Split(status.String(), "\n")
for _, line := range statusLines {
trimmed := strings.TrimSpace(line)
if strings.HasPrefix(trimmed, "D") {
path := strings.TrimPrefix(trimmed, "D ")
_, err := w.Remove(path)
if err != nil {
log.Fatalf("could not delete extra file %s: %v", path, err)
}
}
}
var hashes []plumbing.Hash
var pushRefspecs []config.RefSpec
@ -353,10 +368,10 @@ func ProcessRPM(pd *ProcessData) {
}
hashString := obj.Hash.String()
pushedHashes = append(pushedHashes, fmt.Sprintf("%s:%s", md.pushBranch, hashString))
latestHashForBranch[md.pushBranch] = hashString
}
err := json.NewEncoder(os.Stdout).Encode(pushedHashes)
err := json.NewEncoder(os.Stdout).Encode(latestHashForBranch)
if err != nil {
log.Fatalf("could not print hashes")
}