Skip to content

Commit

Permalink
Merge pull request #1465 from jenkins-x/tracepr
Browse files Browse the repository at this point in the history
fix: make /test work with branches
  • Loading branch information
jenkins-x-bot authored Nov 15, 2023
2 parents 1dc0313 + cd4374c commit 5ddff2b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions pkg/config/job/presubmit.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Presubmit struct {
JenkinsSpec *JenkinsSpec `json:"jenkins_spec,omitempty"`

// We'll set these when we load it.
// re *regexp.Regexp // from Trigger.
re *regexp.Regexp // from Trigger.
}

// SetDefaults initializes default values
Expand Down Expand Up @@ -91,6 +91,7 @@ func (p *Presubmit) SetRegexes() error {

// ClearCompiledRegexes compiles and validates all the regular expressions
func (p *Presubmit) ClearCompiledRegexes() {
p.re = nil
p.Brancher.re = nil
p.Brancher.reSkip = nil
p.RegexpChangeMatcher.reChanges = nil
Expand Down Expand Up @@ -153,12 +154,12 @@ func (p Presubmit) TriggerMatches(body string) bool {
return body == p.Trigger
}
}
return p.Trigger != "" && re != nil && re.MatchString(body)
return re != nil && re.MatchString(body)
}

// ContextRequired checks whether a context is required from github points of view (required check).
func (p Presubmit) ContextRequired() bool {
return !p.Optional && !p.SkipReport
return !(p.Optional || p.SkipReport)
}

// Validate validates job base
Expand Down
1 change: 1 addition & 0 deletions pkg/jobutil/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func FilterPresubmits(filter Filter, changes job.ChangedFilesProvider, branch st
for _, presubmit := range presubmits {
matches, forced, defaults := filter(presubmit)
if !matches {
logger.WithField("presubmit", presubmit).Trace("doesn't match command filter")
continue
}
shouldRun, err := presubmit.ShouldRun(branch, changes, forced, defaults)
Expand Down
3 changes: 2 additions & 1 deletion pkg/plugins/trigger/generic-comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ func handleGenericComment(c Client, trigger *plugins.Trigger, gc scmprovider.Gen
if commentAuthor == botName {
c.Logger.Warn("Comment is made by the bot, for production installs it is recommended to use a different bot user account that your personal one")
}

c.Logger.WithField("event", gc).Trace("Generic comment event")
pr, err := c.SCMProviderClient.GetPullRequest(org, repo, number)
if err != nil {
return err
}
c.Logger.WithField("pull_request", pr).Trace("Fetched pull request")

// Skip untrusted users comments.
trusted, err := TrustedUser(c.SCMProviderClient, trigger, commentAuthor, org, repo)
Expand Down
6 changes: 2 additions & 4 deletions pkg/plugins/trigger/generic-comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ func TestHandleGenericComment(t *testing.T) {
AddedLabels: issueLabels(labels.OkToTest),
RemovedLabels: issueLabels(labels.NeedsOkToTest),
},
/* TODO
{
name: "/test of branch-sharded job",
Author: "trusted-member",
Expand All @@ -557,7 +556,7 @@ func TestHandleGenericComment(t *testing.T) {
"org/repo": {
{
Base: job.Base{
Name: "jab",
Name: "master-jab",
},
Brancher: job.Brancher{Branches: []string{"master"}},
Reporter: job.Reporter{
Expand All @@ -568,7 +567,7 @@ func TestHandleGenericComment(t *testing.T) {
},
{
Base: job.Base{
Name: "jab",
Name: "release-jab",
},
Brancher: job.Brancher{Branches: []string{"release"}},
Reporter: job.Reporter{
Expand Down Expand Up @@ -617,7 +616,6 @@ func TestHandleGenericComment(t *testing.T) {
},
ShouldReport: true,
},
*/
{
name: "branch-sharded job. no shard matches base branch. Skipped statuses elided.",
Author: "trusted-member",
Expand Down

0 comments on commit 5ddff2b

Please sign in to comment.