-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
feat: badge support tag #32451
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
feat: badge support tag #32451
Conversation
|
Maybe |
|
Do you mean I need to support |
Or |
|
Done. |
| var ref string | ||
| switch { | ||
| case useLatestTag: | ||
| tags, _, err := ctx.Repo.GitRepo.GetTagInfos(0, 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.
I think you should use a function like GetLatestReleaseByRepoID to do that.
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.
So we need the tag of the latest release here? Do we need to rename it to latest_release_tag?
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.
No. All tags have been synced into databases. They shared the same table with releases.
| if len(tags) != 0 { | ||
| tag = tags[0].Name | ||
| } else { | ||
| tag = "" // return empty result on no tag |
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.
If it's empty, we should return error.
| case branch != "": | ||
| ref = fmt.Sprintf("refs/heads/%s", branch) | ||
| default: | ||
| branch = ctx.Repo.Repository.DefaultBranch |
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 assign statement is unnecessary.
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.
Should I
if useLatestTag {
tag = "xxx"
}
switch {
// ...
}
or add a fallthrough?
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.
I think it's also OK we handle useLatestTag before switch.
Add a
tagparameter to the badge.svg endpoint. Whenbranchis empty, it will usetagto search for the workflow run. This is useful for badges for release.e.g. https://example.com/org/repo/actions/workflows/release.yaml/badge.svg?tag=h4&event=release