Skip to content

Conversation

fbenkstein
Copy link
Contributor

@fbenkstein fbenkstein commented Dec 24, 2024

Add a "stg name" command that works like "stg id" but returns the patch name instead of the revision. This can be useful for scripting and some command aliases.

I often use this like this to update PRs:

  git push fbenkstein +$(stg id 0):refs/heads/$(stg name 0)

This is a generalization of the "stg next" command: "stg next" is now (almost) equivalent to "stg name +1".

@jpgrayson
Copy link
Collaborator

The behavior of this new stg name command is substantially similar to stg series --no-prefix (and stg series --no-prefix --showbranch). I have previously considered adding a stg name command, but I have been hesitant because stg series has always proven sufficient in scripting contexts.

I'm wondering if you were aware of the similar capability of stg series --no-prefix? And also whether you considered implementing name as one of the default aliases?

All that said, I think I'm in favor of going ahead with having this new command.

@fbenkstein
Copy link
Contributor Author

The behavior of this new stg name command is substantially similar to stg series --no-prefix (and stg series --no-prefix --showbranch). I have previously considered adding a stg name command, but I have been hesitant because stg series has always proven sufficient in scripting contexts.

I'm wondering if you were aware of the similar capability of stg series --no-prefix? And also whether you considered implementing name as one of the default aliases?

All that said, I think I'm in favor of going ahead with having this new command.

I did use an alias of name = stg series --no-prefix --short=0 to give me the name of the current patch. To make it give the name of a different patch I need to drop the --short=0 which makes it a bit annoying to create an alias. Maybe a shell alias could work but I never bothered to implement it. The other reason for a dedicated command is the ability to translate from commit ids back to patch names, for example when getting a workflow failure email from Github. I tried briefly to combine stg series --no-prefix -i with awk but couldn't make it work right (IIRC there was an issue with the default awk on macOS behaving differently than gawk on Linux). We could fold this into stg series but I feel like this command already does a lot of things.

@jpgrayson
Copy link
Collaborator

The behavior of this new stg name command is substantially similar to stg series --no-prefix (and stg series --no-prefix --showbranch). I have previously considered adding a stg name command, but I have been hesitant because stg series has always proven sufficient in scripting contexts.
I'm wondering if you were aware of the similar capability of stg series --no-prefix? And also whether you considered implementing name as one of the default aliases?
All that said, I think I'm in favor of going ahead with having this new command.

I did use an alias of name = stg series --no-prefix --short=0 to give me the name of the current patch. To make it give the name of a different patch I need to drop the --short=0 which makes it a bit annoying to create an alias.

Makes sense that a stg series alias cannot gracefully handle the case where a user doesn't provide an explicit revision on the command line.

I mostly just wanted to make sure that you had considered stg series, so ✔️

The only change I want before merging is to use --showbranch instead of --qualified for consistency with stg series.

Thanks for this PR!

Add a "stg name" command that works like "stg id" but returns the patch
name instead of the revision. This can be useful for scripting and some
command aliases. This is a generalization of the "stg next" command:
"stg next" is now equivalent to "stg name +1".
@fbenkstein
Copy link
Contributor Author

Thanks for this PR!

You're welcome. And thank you for maintaining stg and rewriting it in Rust. I really like how well-written the code is. It makes it very easy to understand and extend.

@jpgrayson jpgrayson merged commit 5496bdd into stacked-git:master Dec 26, 2024
10 checks passed
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.

2 participants