fixing against new .proto files
This commit is contained in:
parent
9c87e1a040
commit
6d7d74feb4
27
doPatch.go
27
doPatch.go
|
@ -103,33 +103,28 @@ func doPatch() error {
|
||||||
var changed bool
|
var changed bool
|
||||||
newpatches := forgepb.NewPatches()
|
newpatches := forgepb.NewPatches()
|
||||||
for pset := range me.forge.Patchsets.IterAll() {
|
for pset := range me.forge.Patchsets.IterAll() {
|
||||||
log.Info(pset.Uuid)
|
pset.PrintTable()
|
||||||
for patch := range pset.Patches.IterAll() {
|
for patch := range pset.Patches.IterAll() {
|
||||||
if setNewCommitHash(patch) {
|
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 == "na" {
|
if newpatches.AppendByPatchId(patch) {
|
||||||
newpatches.Append(patch)
|
log.Info("patchId added here", patch.PatchId)
|
||||||
log.Info("apply this patch?")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
for patch := range pset.Patches.IterAll() {
|
|
||||||
if repo, ok := me.forge.IsPatchApplied(patch); ok {
|
|
||||||
log.Info("\tfound patch in repo", repo.Namespace, patch.Filename)
|
|
||||||
} else {
|
} else {
|
||||||
log.Info("\tdid not find patch", patch.CommitHash, patch.NewHash, patch.Filename)
|
log.Info("patchId already here", patch.PatchId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
if err := me.forge.SavePatchsets(); err != nil {
|
if err := me.forge.SavePatchsets(); err != nil {
|
||||||
log.Warn("savePatchsets() failed", err)
|
log.Warn("savePatchsets() failed", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
me.forge.Patchsets.PrintTable()
|
newpatches.PrintTable()
|
||||||
if newpatches.Len() != 0 {
|
if newpatches.Len() != 0 {
|
||||||
for patch := range newpatches.IterAll() {
|
for patch := range newpatches.IterAll() {
|
||||||
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
|
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
|
||||||
|
|
|
@ -173,52 +173,35 @@ func findCommitBySubject(subject string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if PB changed
|
// returns true if PB changed
|
||||||
func setNewCommitHash(patch *forgepb.Patch) bool {
|
func setNewCommitHash(patch *forgepb.Patch) error {
|
||||||
// parts := strings.Fields(patch.Comment)
|
|
||||||
|
|
||||||
repo := me.forge.FindByGoPath(patch.Namespace)
|
repo := me.forge.FindByGoPath(patch.Namespace)
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
log.Info("could not find repo", patch.Namespace)
|
return log.Errorf("could not find repo %s", patch.Namespace)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
comment := cleanSubject(patch.Comment)
|
comment := cleanSubject(patch.Comment)
|
||||||
|
|
||||||
if patch.NewHash == "" {
|
if patch.NewHash != "" {
|
||||||
log.Info("init() new patch to 'na' ", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
|
return nil
|
||||||
patch.NewHash = "na"
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
os.Chdir(repo.GetFullPath())
|
os.Chdir(repo.GetFullPath())
|
||||||
newhash, err := findCommitBySubject(comment)
|
newhash, err := findCommitBySubject(comment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("patch: not found hash:", 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)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
if patch.NewHash == newhash {
|
if patch.NewHash == newhash {
|
||||||
// patch was already set
|
// patch was already set
|
||||||
return false
|
return nil
|
||||||
}
|
}
|
||||||
if patch.NewHash != "na" {
|
if patch.NewHash != "" {
|
||||||
log.Infof("patch: hash MISMATCH %s old=%s new=%s name=%s\n", patch.Namespace, patch.NewHash, newhash, comment)
|
log.Infof("patch: hash MISMATCH %s old=%s new=%s name=%s\n", patch.Namespace, patch.NewHash, newhash, comment)
|
||||||
return false
|
return nil
|
||||||
}
|
}
|
||||||
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 true
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func setNewCommitHashLoop(p *forgepb.Set) bool {
|
|
||||||
var done bool = true
|
|
||||||
for patch := range p.Patches.IterAll() {
|
|
||||||
setNewCommitHashLoop(patch)
|
|
||||||
}
|
|
||||||
|
|
||||||
return done
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
|
func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
|
||||||
for patch := range pset.Patches.IterAll() {
|
for patch := range pset.Patches.IterAll() {
|
||||||
comment := cleanSubject(patch.Comment)
|
comment := cleanSubject(patch.Comment)
|
||||||
|
@ -251,7 +234,7 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if patch.NewHash != "na" {
|
if patch.NewHash != "" {
|
||||||
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -301,7 +284,7 @@ func findExpired() *forgepb.Patches {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if patch.NewHash != "na" {
|
if patch.NewHash != "" {
|
||||||
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
||||||
found.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
|
found.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -117,11 +117,8 @@ func applyPatchLabel(p *forgepb.Patch) string {
|
||||||
// log.Info("Could not figure out repo path", rn)
|
// log.Info("Could not figure out repo path", rn)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if p.NewHash == "na" {
|
|
||||||
return "git am"
|
|
||||||
}
|
|
||||||
if p.NewHash == "" {
|
if p.NewHash == "" {
|
||||||
return "new"
|
return "git am"
|
||||||
}
|
}
|
||||||
return "done"
|
return "done"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue