-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pretty up previous TFC runs URLs list via markdown tables instead of just a list of URLs #35
Pretty up previous TFC runs URLs list via markdown tables instead of just a list of URLs #35
Conversation
…le item Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
pkg/vcs/github/client.go
Outdated
runUrlRaw := utils.CaptureSubstring(runUrl, "[", "]") | ||
runUrlSplit := strings.Split(runUrlRaw, "/") | ||
// The run ID is the last part of the run URL, and it looks like run-abcd12345... | ||
runID := runUrlSplit[len(runUrlSplit)-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a check to ensure that runUrlSplit > 0 so it won't panic
pkg/vcs/gitlab/client.go
Outdated
runUrlRaw := utils.CaptureSubstring(runUrl, "[", "]") | ||
runUrlSplit := strings.Split(runUrlRaw, "/") | ||
// The run ID is the last part of the run URL, and it looks like run-abcd12345... | ||
runID := runUrlSplit[len(runUrlSplit)-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a check to ensure that runUrlSplit > 0 so it won't panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that - I also added a else condition in the event the runUrlSplit check fails to just fallback to original URL that was used before just so the has something rather than just an awkward blank table entry
pkg/vcs/gitlab/client.go
Outdated
} | ||
|
||
// 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) | ||
if oldRunBlockTest != "" { | ||
oldRunBlock = oldRunBlockTest | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be rewritten like this
oldRunBlock = "\n"
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
}
pkg/vcs/github/client.go
Outdated
} | ||
|
||
// 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) | ||
if oldRunBlockTest != "" { | ||
oldRunBlock = oldRunBlockTest | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be rewritten like this
oldRunBlock = "\n"
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
}
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Signed-off-by: Alec Hinh <[email protected]>
Closes #34
Updates the placement of the previous TFC run URLs to use a markdown table instead.
Previously, the list looked like this:
Here is the proposed format:
Additionally, using tables I added a
Created at
field to show an exact timestamp of when the run was created (based on the MR creation timestamp) to allow for an easier view of when a TF run was made.And for compatibility with Github, I replaced the airplane_arriving emoji with 📥 as Github doesn't have the airplane arriving emoji.
Github testing
Unfortunately, I wasn't able to test these changes on Github as it doesn't seem like Github uses the MR run headers that Gitlab does. So while I've tested to make sure Github's functionality wasn't broken by these changes, I wasn't able to verify if the changes I ported from Gitlab also work on Github.