Skip to content

Commit

Permalink
fix/pr 0 (#1691)
Browse files Browse the repository at this point in the history
* support noop pr service to avoid PR interactions post merge

* fix noop issue
  • Loading branch information
motatoes authored Sep 4, 2024
1 parent e11d380 commit 9039c3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libs/spec/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ type VCSProviderBasic struct{}

func (v VCSProviderBasic) GetPrService(vcsSpec VcsSpec) (ci.PullRequestService, error) {
switch vcsSpec.VcsType {
case "noop":
return ci.MockPullRequestManager{}, nil
case "github":
token := os.Getenv("GITHUB_TOKEN")
if token == "" {
Expand All @@ -200,6 +202,8 @@ func (v VCSProviderBasic) GetPrService(vcsSpec VcsSpec) (ci.PullRequestService,

func (v VCSProviderBasic) GetOrgService(vcsSpec VcsSpec) (ci.OrgService, error) {
switch vcsSpec.VcsType {
case "noop":
return ci.MockPullRequestManager{}, nil
case "github":
token := os.Getenv("GITHUB_TOKEN")
if token == "" {
Expand Down
4 changes: 4 additions & 0 deletions next/services/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func RunQueuesStateMachine(queueItem *model.DiggerRunQueueItem, service ci.PullR
log.Printf("could not get spec: %v", err)
return fmt.Errorf("could not get spec: %v", err)
}
// temp: override vcs type to use "noop"
spec.VCS.VcsType = "noop"

vcsToken, err := GetVCSTokenFromJob(*planJob, gh)
if err != nil {
Expand Down Expand Up @@ -150,6 +152,8 @@ func RunQueuesStateMachine(queueItem *model.DiggerRunQueueItem, service ci.PullR
log.Printf("could not get spec: %v", err)
return fmt.Errorf("could not get spec: %v", err)
}
// temp: override vcs type to use "noop"
spec.VCS.VcsType = "noop"

vcsToken, err := GetVCSTokenFromJob(*job, gh)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion next/services/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ func GetRunNameFromJob(job model.DiggerJob) (*string, error) {
requestedBy := jobSpec.RequestedBy
prNumber := *jobSpec.PullRequestNumber

runName := fmt.Sprintf("[%v] %v %v By: %v PR: %v", batchIdShort, diggerCommand, projectName, requestedBy, prNumber)
runName := fmt.Sprintf("[%v] %v %v By: %v", batchIdShort, diggerCommand, projectName, requestedBy)
if prNumber != 0 {
runName += fmt.Sprintf(" PR: %v", prNumber)
}
return &runName, nil
}

Expand Down

0 comments on commit 9039c3a

Please sign in to comment.