mislav / hub

A command-line tool that makes git easier to use with GitHub.
https://hub.github.com/
MIT License
22.78k stars 2.2k forks source link

[Feature Idea] Reuse the release draft when execute `hub release create` with the same name #2201

Open LinuxSuRen opened 5 years ago

LinuxSuRen commented 5 years ago

This is my case. I use release-drafter to generate my release draft automatic. So it's good to reuse this when I execute hub release create sametag.

mislav commented 5 years ago

Thank you for explaining your use-case! Just to be clear: what is the proposed pending tag for drafts made by release-drafter?

LinuxSuRen commented 5 years ago

The tag can be configured by release-drafter. Here is an example config https://github.com/jenkins-zh/jenkins-cli/blob/master/.github/release-drafter.yml.

mislav commented 5 years ago

Something that should work right now is:

hub release edit v1.2.3 --draft=false

The text editor should be populated with the existing draft, and when you save the release, it should be published to non-draft status.

Is this usage acceptable to you, or do you think that this should be the implicit behavior of hub release create v1.2.3 when a draft for v1.2.3 exists?

LinuxSuRen commented 5 years ago

Below cmd line could resolve my problems partly:

hub release edit v1.2.3 --draft=false

It's not working if I just want to release that draft. For example, I release this by Jenkins or other CI server.

Another situation is that I don't expect hub release create v1.2.3 creating a new one if v1.2.3 exists.

mislav commented 5 years ago

It's not working if I just want to release that draft.

Can you explain more about what is not working about that command?

LinuxSuRen commented 5 years ago

It's not convenience if I already have a release draft and I just want to publish the release draft.

It's not working if I just want to release that draft.

This expression may not be accurate.

mislav commented 5 years ago

It's not convenience if I already have a release draft and I just want to publish the release draft.

I see. Is this because a text editor opens interactively, and you want to skip that? You could use:

$ hub release edit v1.2.3 --draft=false --message=""

Even though I understand that this invocation is considerably more clunky and counter-intuitive compared to hub release create v1.2.3, it is something that should work today, plus it more closely maps the action that is happening; i.e. an existing draft release is being edited/published, rather than a new release being created.

I will keep this open to contemplate the possible change to hub release create behavior but I cannot make any guarantees that we will make it “magic” for now. There are pros and cons that could be made in either direction. 🤔

LinuxSuRen commented 5 years ago

Once I execute cmd below, the release is still under draft status:

$ hub release edit v1.2.3 --draft=false --message=""
mislav commented 5 years ago

Once I execute cmd below, the release is still under draft status:

If that is true, that must be a bug. Can you see if you can help debug it in verbose mode?

HUB_VERBOSE=1 hub release edit ...

Also, make sure that you are on the latest hub version. We have a test that covers this scenario:

https://github.com/github/hub/blob/2cf4d7b5b0067f3aa89ddf9880ab4746cf923236/features/release.feature#L481

I have just tried it manually, and hub release edit v3.0.1 --draft=false -m "" worked for me to publish a draft that specified the v3.0.1 tag name. The tag was created off the target branch, and the release no longer has the "draft" marker.

So because I cannot reproduce this, it would be great if you could and supplied me with some debugging data so we could fix this! Thank you 🙇

LinuxSuRen commented 5 years ago

I tried with hub release edit v0.0.16 --draft=false --message="". My repo is https://github.com/LinuxSuRen/demo/releases.

It could be my false about this release. Please tell me if it's true.

mislav commented 5 years ago

I tried with hub release edit v0.0.16 --draft=false --message="".

Could you tell us what happened when you tried this? Did the text editor open? Did the draft release remain marked as "draft" after this? Have you tried the HUB_VERBOSE mode as suggested above to try debug what happened here and provide us with more info? Thank you!

LinuxSuRen commented 5 years ago

Nothing happened after I execute the command: HUB_VERBOSE=1 hub release edit v0.0.16 --draft=false --message="". The editor was not opened. The release is still under the draft status. You can find the output below:

$ git rev-parse -q --git-dir
$ git remote -v
$ git config --get-all hub.host
> GET https://api.github.com/repos/LinuxSuRen/demo/releases?per_page=100
> Authorization: token [REDACTED]
> Accept: application/vnd.github.v3+json;charset=utf-8
< HTTP 200
[{"url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397843","assets_url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397843/assets","upload_url":"https://uploads.github.com/repos/LinuxSuRen/demo/releases/19397843/assets{?name,label}","html_url":"https://github.com/LinuxSuRen/demo/releases/tag/v0.0.16","id":19397843,"node_id":"MDc6UmVsZWFzZTE5Mzk3ODQz","tag_name":"v0.0.16","target_commitish":"master","name":"good","draft":false,"author":{"login":"LinuxSuRen","id":1450685,"node_id":"MDQ6VXNlcjE0NTA2ODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1450685?v=4","gravatar_id":"","url":"https://api.github.com/users/LinuxSuRen","html_url":"https://github.com/LinuxSuRen","followers_url":"https://api.github.com/users/LinuxSuRen/followers","following_url":"https://api.github.com/users/LinuxSuRen/following{/other_user}","gists_url":"https://api.github.com/users/LinuxSuRen/gists{/gist_id}","starred_url":"https://api.github.com/users/LinuxSuRen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinuxSuRen/subscriptions","organizations_url":"https://api.github.com/users/LinuxSuRen/orgs","repos_url":"https://api.github.com/users/LinuxSuRen/repos","events_url":"https://api.github.com/users/LinuxSuRen/events{/privacy}","received_events_url":"https://api.github.com/users/LinuxSuRen/received_events","type":"User","site_admin":false},"prerelease":false,"created_at":"2019-01-14T05:46:39Z","published_at":"2019-08-20T08:20:34Z","assets":[],"tarball_url":"https://api.github.com/repos/LinuxSuRen/demo/tarball/v0.0.16","zipball_url":"https://api.github.com/repos/LinuxSuRen/demo/zipball/v0.0.16","body":""},{"url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397701","assets_url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397701/assets","upload_url":"https://uploads.github.com/repos/LinuxSuRen/demo/releases/19397701/assets{?name,label}","html_url":"https://github.com/LinuxSuRen/demo/releases/tag/untagged-a387221e8bb16798bbbd","id":19397701,"node_id":"MDc6UmVsZWFzZTE5Mzk3NzAx","tag_name":"untagged-a387221e8bb16798bbbd","target_commitish":"master","name":"v0.0.16","draft":true,"author":{"login":"LinuxSuRen","id":1450685,"node_id":"MDQ6VXNlcjE0NTA2ODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1450685?v=4","gravatar_id":"","url":"https://api.github.com/users/LinuxSuRen","html_url":"https://github.com/LinuxSuRen","followers_url":"https://api.github.com/users/LinuxSuRen/followers","following_url":"https://api.github.com/users/LinuxSuRen/following{/other_user}","gists_url":"https://api.github.com/users/LinuxSuRen/gists{/gist_id}","starred_url":"https://api.github.com/users/LinuxSuRen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinuxSuRen/subscriptions","organizations_url":"https://api.github.com/users/LinuxSuRen/orgs","repos_url":"https://api.github.com/users/LinuxSuRen/repos","events_url":"https://api.github.com/users/LinuxSuRen/events{/privacy}","received_events_url":"https://api.github.com/users/LinuxSuRen/received_events","type":"User","site_admin":false},"prerelease":false,"created_at":"2019-08-20T08:16:03Z","published_at":null,"assets":[],"tarball_url":null,"zipball_url":null,"body":"sample for v0.0.16"},{"url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397564","assets_url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397564/assets","upload_url":"https://uploads.github.com/repos/LinuxSuRen/demo/releases/19397564/assets{?name,label}","html_url":"https://github.com/LinuxSuRen/demo/releases/tag/v0.0.14","id":19397564,"node_id":"MDc6UmVsZWFzZTE5Mzk3NTY0","tag_name":"v0.0.14","target_commitish":"master","name":"v0.0.14","draft":false,"author":{"login":"LinuxSuRen","id":1450685,"node_id":"MDQ6VXNlcjE0NTA2ODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1450685?v=4","gravatar_id":"","url":"https://api.github.com/users/LinuxSuRen","html_url":"https://github.com/LinuxSuRen","followers_url":"https://api.github.com/users/LinuxSuRen/followers","following_url":"https://api.github.com/users/LinuxSuRen/following{/other_user}","gists_url":"https://api.github.com/users/LinuxSuRen/gists{/gist_id}","starred_url":"https://api.github.com/users/LinuxSuRen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinuxSuRen/subscriptions","organizations_url":"https://api.github.com/users/LinuxSuRen/orgs","repos_url":"https://api.github.com/users/LinuxSuRen/repos","events_url":"https://api.github.com/users/LinuxSuRen/events{/privacy}","received_events_url":"https://api.github.com/users/LinuxSuRen/received_events","type":"User","site_admin":false},"prerelease":false,"created_at":"2019-01-14T05:46:39Z","published_at":"2019-08-20T08:13:39Z","assets":[],"tarball_url":"https://api.github.com/repos/LinuxSuRen/demo/tarball/v0.0.14","zipball_url":"https://api.github.com/repos/LinuxSuRen/demo/zipball/v0.0.14","body":"Sample content. 1"}]
> PATCH https://api.github.com/repos/LinuxSuRen/demo/releases/19397843
> Authorization: token [REDACTED]
> Accept: application/vnd.github.v3+json;charset=utf-8
{"draft":false}
< HTTP 200
{"url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397843","assets_url":"https://api.github.com/repos/LinuxSuRen/demo/releases/19397843/assets","upload_url":"https://uploads.github.com/repos/LinuxSuRen/demo/releases/19397843/assets{?name,label}","html_url":"https://github.com/LinuxSuRen/demo/releases/tag/v0.0.16","id":19397843,"node_id":"MDc6UmVsZWFzZTE5Mzk3ODQz","tag_name":"v0.0.16","target_commitish":"master","name":"good","draft":false,"author":{"login":"LinuxSuRen","id":1450685,"node_id":"MDQ6VXNlcjE0NTA2ODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1450685?v=4","gravatar_id":"","url":"https://api.github.com/users/LinuxSuRen","html_url":"https://github.com/LinuxSuRen","followers_url":"https://api.github.com/users/LinuxSuRen/followers","following_url":"https://api.github.com/users/LinuxSuRen/following{/other_user}","gists_url":"https://api.github.com/users/LinuxSuRen/gists{/gist_id}","starred_url":"https://api.github.com/users/LinuxSuRen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinuxSuRen/subscriptions","organizations_url":"https://api.github.com/users/LinuxSuRen/orgs","repos_url":"https://api.github.com/users/LinuxSuRen/repos","events_url":"https://api.github.com/users/LinuxSuRen/events{/privacy}","received_events_url":"https://api.github.com/users/LinuxSuRen/received_events","type":"User","site_admin":false},"prerelease":false,"created_at":"2019-01-14T05:46:39Z","published_at":"2019-08-20T08:20:34Z","assets":[],"tarball_url":"https://api.github.com/repos/LinuxSuRen/demo/tarball/v0.0.16","zipball_url":"https://api.github.com/repos/LinuxSuRen/demo/zipball/v0.0.16","body":""}