Skip to content

Specify target to local tag SHA in release create - #5104

Merged
mislav merged 10 commits into
trunkfrom
fix-release-tag-issue
Feb 15, 2022
Merged

mislav merged 10 commits into
trunkfrom
fix-release-tag-issue

Conversation

@samcoe

@samcoe samcoe commented Jan 26, 2022 •

Copy link
Copy Markdown
Contributor

This PR sets the target_commitish parameter to the local tag SHA when present for the release create command. This prevents the API from creating a new tag pointed at the incorrect SHA if the local tag has not been pushed.

cc #4571 (review)
Supersedes #4571
Closes #4357

@samcoe samcoe self-assigned this Jan 26, 2022
@samcoe
samcoe requested a review from a team as a code owner January 26, 2022 11:21
@samcoe
samcoe requested review from mislav and vilmibm and removed request for a team January 26, 2022 11:21

@mislav mislav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach! Thank you

Comment thread pkg/cmd/release/create/create.go Outdated
Comment thread pkg/cmd/release/create/create.go Outdated
@spenserblack

Copy link
Copy Markdown
Contributor

If I'm understanding this change correctly, this will set the target to the SHA of the tag, not the tag itself, right? I'm concerned that this will trigger the API to create a new tag with the same name, losing any tag annotations or GPG signatures that were created locally in the process.
IMO I found the behavior described in #4571 (review) to be less confusing and surprising behavior.

if a local tag exists and --target was not given, use the local tag name as the value for --target, which should fail if the tag wasn't pushed.

Though I admit that I don't know how common it is for a tag to be signed or annotated, so I'm unsure if my experience is common enough to be a concern.

Just my 2 cents, thank you to everyone for your hard work maintaining gh!

@samcoe
samcoe requested a review from mislav January 27, 2022 09:32

@mislav mislav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@mislav

mislav commented Jan 28, 2022

Copy link
Copy Markdown
Contributor

IMO I found the behavior described in #4571 (review) to be less confusing and surprising behavior.

if a local tag exists and --target was not given, use the local tag name as the value for --target, which should fail if the tag wasn't pushed.

Though I admit that I don't know how common it is for a tag to be signed or annotated, so I'm unsure if my experience is common enough to be a concern.

Hmm that's a good point about tag name vs. commit SHA; thank you @spenserblack.

@samcoe Do you think we could change to that approach to avoid potentially recreating the unpushed tag on the remote?

@samcoe
samcoe force-pushed the fix-release-tag-issue branch from 4122272 to d296d7e Compare February 3, 2022 13:17
@samcoe

samcoe commented Feb 3, 2022

Copy link
Copy Markdown
Contributor Author

@mislav Ok I changed the approach. This one is definitely a bit more complicated and adds more complexity to the already complex release create functionality. Here is an example of what it looks like when there is an non-pushed local tag:

Screen Shot 2022-02-03 at 1 54 11 PM

@samcoe
samcoe requested a review from mislav February 3, 2022 13:45
Comment thread pkg/cmd/release/create/create.go Outdated
Comment thread pkg/cmd/release/create/http.go Outdated
Comment thread pkg/cmd/release/create/http.go Outdated
Comment thread pkg/cmd/release/create/http.go Outdated
Comment thread pkg/cmd/release/create/create.go
Comment thread pkg/cmd/release/create/create.go Outdated
Comment thread pkg/cmd/release/create/create.go Outdated
@samcoe
samcoe requested a review from mislav February 4, 2022 11:58
Comment thread pkg/cmd/release/create/create.go Outdated
Comment thread pkg/cmd/release/create/http.go Outdated

var tagDescription string
if opts.RepoOverride == "" {
tagDescription, _ = gitTagInfo(opts.TagName)

@samcoe samcoe Feb 14, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using tagDescription as an indicator that the local tag exists. From my testing that has worked out fine, but are there any scenarios where a tag exists locally and the tag description is blank?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitTagInfo should exit with an error status if the tag was not found. Perhaps you can use the lack of an error return value as an indicator that the tag was found?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I tried this locally and git returned a 0 status when a tag didn't exist.

@samcoe
samcoe requested a review from mislav February 14, 2022 09:45

@mislav mislav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your hard work and doing all the iterations of this implementation! Only nitpicks remain 🙌


var tagDescription string
if opts.RepoOverride == "" {
tagDescription, _ = gitTagInfo(opts.TagName)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitTagInfo should exit with an error status if the tag was not found. Perhaps you can use the lack of an error return value as an indicator that the tag was found?

Comment thread api/queries_repo.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should gh release create push the local tag if it exists?

4 participants