Skip to content

Commit

Permalink
Only allow sync for Open PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oded-B committed Jul 2, 2024
1 parent 80f3443 commit c235871
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/pkg/githubapi/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,14 @@ func handleCommentPrEvent(ghPrClientDetails GhPrClientDetails, ce *github.IssueC
_, _ = ghPrClientDetails.GetRef()
_, _ = ghPrClientDetails.GetSHA()

// This part should only happen on edits of bot comments - this part is about catching checkbox changes
if *ce.Action == "edited" && *ce.Comment.User.Login == botIdentity {
// This part should only happen on edits of bot comments on open PRs (I'm not testing Issue vs PR as Telefonsitka only creates PRs at this point)
if *ce.Action == "edited" && *ce.Comment.User.Login == botIdentity && *ce.Issue.State == "open" {
checkboxPattern := `(?m)^\s*-\s*\[(.)\]\s*<!-- telefonistka-argocd-branch-sync -->.*$`
checkboxWaschecked, checkboxIsChecked := analyzeCommentUpdateCheckBox(*ce.Comment.Body, *ce.Changes.Body.From, checkboxPattern)
if !checkboxWaschecked && checkboxIsChecked {
ghPrClientDetails.PrLogger.Infof("Sync Checkbox was checked")
if config.AllowSyncArgoCDAppfromBranchPathRegex != "" {
ghPrClientDetails.getPrMetadata(ce.Issue.GetBody()) // TODO is issue is not a PR but an actual issue, this will fail?

ghPrClientDetails.getPrMetadata(ce.Issue.GetBody())
componentPathList, err := generateListOfChangedComponentPaths(ghPrClientDetails, config)
if err != nil {
ghPrClientDetails.PrLogger.Errorf("Failed to get list of changed components: err=%s\n", err)
Expand Down

0 comments on commit c235871

Please sign in to comment.