apply patches
This commit is contained in:
parent
6d7d74feb4
commit
e0520ca96d
89
doPatch.go
89
doPatch.go
|
@ -101,21 +101,24 @@ func doPatch() error {
|
||||||
|
|
||||||
if argv.Patch.List != nil {
|
if argv.Patch.List != nil {
|
||||||
var changed bool
|
var changed bool
|
||||||
newpatches := forgepb.NewPatches()
|
newpatches := new(forgepb.Set)
|
||||||
|
newpatches.Patches = forgepb.NewPatches()
|
||||||
for pset := range me.forge.Patchsets.IterAll() {
|
for pset := range me.forge.Patchsets.IterAll() {
|
||||||
pset.PrintTable()
|
pset.PrintTable()
|
||||||
for patch := range pset.Patches.IterAll() {
|
for patch := range pset.Patches.IterAll() {
|
||||||
if err := setNewCommitHash(patch); err != nil {
|
|
||||||
log.Infof("%s bad check on patch failure %v\n", patch.Filename, err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
changed = true
|
changed = true
|
||||||
if patch.NewHash == "" {
|
if patch.NewHash == "" || patch.NewHash == "na" {
|
||||||
if newpatches.AppendByPatchId(patch) {
|
if newpatches.Patches.AppendByPatchId(patch) {
|
||||||
log.Info("patchId added here", patch.PatchId)
|
log.Info("patchId added here", patch.PatchId)
|
||||||
} else {
|
} else {
|
||||||
log.Info("patchId already here", patch.PatchId)
|
log.Info("patchId already here", patch.PatchId)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if err := setNewCommitHash(patch); err != nil {
|
||||||
|
log.Infof("%s bad check on patch failure %v\n", patch.Filename, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Info("newhash set already here", patch.PatchId, patch.NewHash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,38 +127,54 @@ func doPatch() error {
|
||||||
log.Warn("savePatchsets() failed", err)
|
log.Warn("savePatchsets() failed", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Info("NEW PATCHES TABLE")
|
||||||
newpatches.PrintTable()
|
newpatches.PrintTable()
|
||||||
if newpatches.Len() != 0 {
|
for patch := range newpatches.Patches.IterAll() {
|
||||||
for patch := range newpatches.IterAll() {
|
if err := setNewCommitHash(patch); err == nil {
|
||||||
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
|
log.Info("newhash set already here", patch.PatchId, patch.NewHash)
|
||||||
repo := me.forge.FindByGoPath(patch.Namespace)
|
continue
|
||||||
if repo == nil {
|
}
|
||||||
log.Info("\tCould not find namespace:", patch.Namespace)
|
log.Infof("%s is new\n", patch.Filename)
|
||||||
continue
|
repo := me.forge.FindByGoPath(patch.Namespace)
|
||||||
}
|
if repo == nil {
|
||||||
if fhelp.QuestionUser("apply this patch?") {
|
log.Info("\tCould not find namespace:", patch.Namespace)
|
||||||
newhash, err := applyAndTrackPatch(repo, patch)
|
continue
|
||||||
log.Info("apply results:", newhash, err)
|
}
|
||||||
}
|
if fhelp.QuestionUser("apply this patch?") {
|
||||||
|
newhash, err := applyAndTrackPatch(repo, patch)
|
||||||
|
log.Info("apply results:", newhash, err)
|
||||||
}
|
}
|
||||||
return log.Errorf("patches need to be applied")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return doPatchList()
|
|
||||||
applied := findApplied()
|
|
||||||
if applied == nil || applied.Len() == 0 {
|
|
||||||
log.Info("no patches have been appled to the devel branch yet")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// for patch := range applied.IterAll() {
|
|
||||||
// log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
|
|
||||||
// }
|
|
||||||
newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
newpb.PrintTable()
|
|
||||||
return nil
|
return nil
|
||||||
|
/*
|
||||||
|
if newpatches.Len() != 0 {
|
||||||
|
for patch := range newpatches.IterAll() {
|
||||||
|
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
|
||||||
|
repo := me.forge.FindByGoPath(patch.Namespace)
|
||||||
|
if repo == nil {
|
||||||
|
log.Info("\tCould not find namespace:", patch.Namespace)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return log.Errorf("patches need to be applied")
|
||||||
|
}
|
||||||
|
|
||||||
|
// return doPatchList()
|
||||||
|
applied := findApplied()
|
||||||
|
if applied == nil || applied.Len() == 0 {
|
||||||
|
log.Info("no patches have been appled to the devel branch yet")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// for patch := range applied.IterAll() {
|
||||||
|
// log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
|
||||||
|
// }
|
||||||
|
newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
newpb.PrintTable()
|
||||||
|
return nil
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// if nothing, show patches & dirty repos
|
// if nothing, show patches & dirty repos
|
||||||
|
|
|
@ -181,23 +181,20 @@ func setNewCommitHash(patch *forgepb.Patch) error {
|
||||||
|
|
||||||
comment := cleanSubject(patch.Comment)
|
comment := cleanSubject(patch.Comment)
|
||||||
|
|
||||||
if patch.NewHash != "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
os.Chdir(repo.GetFullPath())
|
os.Chdir(repo.GetFullPath())
|
||||||
newhash, err := findCommitBySubject(comment)
|
newhash, err := findCommitBySubject(comment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return log.Errorf("patch: not found hash: %s %s %s %s %v", patch.CommitHash, patch.Namespace, comment, newhash, err)
|
return log.Errorf("patch: not found hash: %s %s %s %s %v", patch.CommitHash, patch.Namespace, comment, newhash, err)
|
||||||
}
|
}
|
||||||
if patch.NewHash == newhash {
|
|
||||||
// patch was already set
|
patchId, err := repo.FindPatchId(newhash)
|
||||||
return nil
|
if err != nil {
|
||||||
}
|
return err
|
||||||
if patch.NewHash != "" {
|
|
||||||
log.Infof("patch: hash MISMATCH %s old=%s new=%s name=%s\n", patch.Namespace, patch.NewHash, newhash, comment)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patch.PatchId = patchId
|
||||||
patch.NewHash = newhash
|
patch.NewHash = newhash
|
||||||
|
|
||||||
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment)
|
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue