Skip to content

Commit

Permalink
Move oldrunblock logic to not execute as an else condition
Browse files Browse the repository at this point in the history
Signed-off-by: Alec Hinh <[email protected]>
  • Loading branch information
ahinh43 committed Aug 7, 2023
1 parent 4aee5a4 commit f09701d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions pkg/vcs/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ func (c *Client) GetOldRunUrls(prID int, fullName string, rootCommentID int) (st

// Github orders comments from earliest -> latest via ID, so we check each comment and take the last match on an "old url" block
oldRunBlockTest := utils.CaptureSubstring(comment.GetBody(), utils.URL_RUN_GROUP_PREFIX, utils.URL_RUN_GROUP_SUFFIX)
// Add a new line for the first table entry so that markdown tabling can properly begin
oldRunBlock = "\n"
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
} else {
// Add a new line for the first table entry so that markdown tabling can properly begin
oldRunBlock = "\n"
}

if os.Getenv("TFBUDDY_DELETE_OLD_COMMENTS") != "" && comment.GetID() != int64(rootCommentID) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/vcs/gitlab/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ func (c *GitlabClient) GetOldRunUrls(mrIID int, project string, rootNoteID int)

// Gitlab default sort is order by created by, so take the last match on this
oldRunBlockTest := utils.CaptureSubstring(note.Body, utils.URL_RUN_GROUP_PREFIX, utils.URL_RUN_GROUP_SUFFIX)
// Add a new line for the first table entry so that markdown tabling can properly begin
oldRunBlock = "\n"
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
} else {
// Add a new line for the first table entry so that markdown tabling can properly begin
oldRunBlock = "\n"
}
if os.Getenv("TFBUDDY_DELETE_OLD_COMMENTS") != "" && note.ID != rootNoteID {
log.Debug().Str("projectID", project).Int("mrIID", mrIID).Msgf("deleting note %d", note.ID)
Expand Down

0 comments on commit f09701d

Please sign in to comment.