fixed bug in parsing non-scorsh commits

lint-refactor
KatolaZ 8 years ago
parent b0aa804366
commit b3e10f839c
  1. 20
      commits.go
  2. 4
      types.go
  3. 2
      workers.go

@ -35,7 +35,7 @@ func check_signature(commit *git.Commit, keyring *openpgp.KeyRing) (signature, s
strings.NewReader(signature)) strings.NewReader(signature))
if err_sig == nil { if err_sig == nil {
fmt.Printf("Good signature \n") debug.log("[commit: %s] Good signature \n", commit.Id())
return signature, signed, nil return signature, signed, nil
} }
err = err_sig err = err_sig
@ -54,6 +54,9 @@ func find_scorsh_message(commit *git.Commit) (string, error) {
// FIXME!!! replace the following with a proper regexp.Match // FIXME!!! replace the following with a proper regexp.Match
idx := strings.Index(msg, sep) idx := strings.Index(msg, sep)
if idx < 0 {
return "", fmt.Errorf("no SCORSH message found\n")
}
return msg[idx:], nil return msg[idx:], nil
} }
@ -114,7 +117,7 @@ func walk_commits(msg SCORSHmsg, w *SCORSHworker) error {
var tags SCORSHclient_msg var tags SCORSHclient_msg
var commit_msg string var commit_msg string
fmt.Printf("Inside parse_commits\n") debug.log("[worker: %s] Inside parse_commits\n", w.Name)
reponame := msg.Repo reponame := msg.Repo
old_rev := msg.Old_rev old_rev := msg.Old_rev
@ -145,6 +148,7 @@ func walk_commits(msg SCORSHmsg, w *SCORSHworker) error {
cur_commit := newrev_commit cur_commit := newrev_commit
// FIXME: replace with a queue of commits
for cur_commit.Id().String() != oldrev_commit.Id().String() { for cur_commit.Id().String() != oldrev_commit.Id().String() {
commit, err := repo.LookupCommit(cur_commit.Id()) commit, err := repo.LookupCommit(cur_commit.Id())
@ -156,16 +160,13 @@ func walk_commits(msg SCORSHmsg, w *SCORSHworker) error {
// Check if the commit contains a scorsh command // Check if the commit contains a scorsh command
commit_msg, err = find_scorsh_message(commit) commit_msg, err = find_scorsh_message(commit)
if err != nil { if err == nil {
log.Printf("[worker: %s] %s\n", w.Name, SCORSHerr(SCORSH_ERR_SIGNATURE))
}
// Check if is the comment contains a valid scorsh message // Check if is the comment contains a valid scorsh message
err = yaml.Unmarshal([]byte(commit_msg), &tags) err = yaml.Unmarshal([]byte(commit_msg), &tags)
if err != nil { if err != nil {
// no scorsh message found // no scorsh message found
log.Printf("[worker: %s] no scorsh message found: %s", err) err = fmt.Errorf("unmarshal error: %s", err)
} else { } else {
// there is a scorsh message there so.... // there is a scorsh message there so....
@ -202,7 +203,10 @@ func walk_commits(msg SCORSHmsg, w *SCORSHworker) error {
} }
} }
} }
} else {
log.Printf("[worker: %s] error parsing commit %s: %s", w.Name, cur_commit.Id().String(), err)
}
// FIXME: ADD ALL THE PARENTS TO THE QUEUE OF COMMITS
cur_commit = commit.Parent(0) cur_commit = commit.Parent(0)
} else { } else {
fmt.Printf("Commit %x not found!\n", cur_commit.Id()) fmt.Printf("Commit %x not found!\n", cur_commit.Id())

@ -43,7 +43,7 @@ type SCORSHworker_cfg struct {
Folder string `yaml:"w_folder"` Folder string `yaml:"w_folder"`
Logfile string `yaml:"w_logfile"` Logfile string `yaml:"w_logfile"`
Tagfile string `yaml:"w_tagfile"` Tagfile string `yaml:"w_tagfile"`
Keyrings []string `yaml:"w_keyrings"` // Keyrings []string `yaml:"w_keyrings"`
Tags []SCORSHtag_cfg `yaml:"w_tags"` Tags []SCORSHtag_cfg `yaml:"w_tags"`
TagKeys map[string]map[string]bool TagKeys map[string]map[string]bool
} }
@ -136,7 +136,7 @@ func (w *SCORSHworker) String() string {
fmt.Fprintf(&buff, "Folder: %s\n", w.Folder) fmt.Fprintf(&buff, "Folder: %s\n", w.Folder)
fmt.Fprintf(&buff, "Logfile: %s\n", w.Logfile) fmt.Fprintf(&buff, "Logfile: %s\n", w.Logfile)
fmt.Fprintf(&buff, "Tagfile: %s\n", w.Tagfile) fmt.Fprintf(&buff, "Tagfile: %s\n", w.Tagfile)
fmt.Fprintf(&buff, "Keyrings: %s\n", w.Keyrings) // fmt.Fprintf(&buff, "Keyrings: %s\n", w.Keyrings)
return buff.String() return buff.String()
} }

@ -30,7 +30,7 @@ func (worker *SCORSHworker) Matches(repo, branch string) bool {
func (w *SCORSHworker) LoadKeyrings() error { func (w *SCORSHworker) LoadKeyrings() error {
w.Keys = make(map[string]openpgp.KeyRing, len(w.Keyrings)) w.Keys = make(map[string]openpgp.KeyRing)
w.TagKeys = make(map[string]map[string]bool) w.TagKeys = make(map[string]map[string]bool)
for _, t := range w.Tags { for _, t := range w.Tags {

Loading…
Cancel
Save