Skip to content
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

Specify the naming or prefix for the jj git push --change xxx #1958

Closed
lazywei opened this issue Aug 2, 2023 · 4 comments · Fixed by #1962
Closed

Specify the naming or prefix for the jj git push --change xxx #1958

lazywei opened this issue Aug 2, 2023 · 4 comments · Fixed by #1962

Comments

@lazywei
Copy link

lazywei commented Aug 2, 2023

Hi,

I've been using sapling and now trying to do the similar thing as push stack. I followed the docs and run commands like

jj git push --change XXX --change YYY

However, the created branch is with naming like

push-otznykxnuusx
push-vlxzuutruspk

My questions are:

  1. Is it possible to specify the naming with the --change flag?
  2. Or is it possible to specify a template, like <username>/push-xxxxxx, to make it easier to work in a collaborated repo?
  3. Since we need to manually specify the base branch when creating the stack PRs with this method, is it possible to add some sort of ordinal naming like push-42-otznykxnuusx or push-pr42-otznykxnuusx so it's easier to spot out the ordering of multiple created branches / PRs?

Thanks!

@thoughtpolice
Copy link
Collaborator

thoughtpolice commented Aug 2, 2023

Quick reply while I'm finishing some stuff up and just checking GH Issues:

  1. You can create a normal branch name with jj branch create <name> -r <rev>, then jj git push --branch <name> instead. By default --change will automatically make that name based on the change ID.

    • If you add more commits, you can continuously use jj branch set when you want to update the PR to point to a new commit, then jj git push again
    • If you jj edit that commit you tagged with a name, and just rework it a bunch as the working copy, you won't need to update the branch pointer, in contrast.
  2. I don't think so, as of right now. But in practice I haven't found it an issue while working on the jj repo with others.

    • For example, I just jj git push -c <id> and it creates a push-<id> branch on this repo. I make a PR, then when I go back to it, I just copy/paste the branch name from the PR, at the top of the page, on GitHub. Because multiple developers use the repo this way, I can just copy/paste those push-xyz IDs from any branch and checkout anyone else's work.
    • So in other words, you just stop worrying about the branch name, and look it up on demand when you actually open the PR. For example, when viewing cli: when restoring to a previous operation, don't roll back git_refs #1541, I would just click the branch name at the top, which copies it into my clipboard image
    • This is pretty GitHub specific, but at least I know @martinvonz and I both push changes and branches this way directly into this repo
    • Not everyone does though! @ilyagr and @arxanas seem to name their branches explicitly.
  3. I'm not sure. In practice I tend to submit multiple --changes at once and encourage people to just read the individual commits. This is partially GitHub's problem because there isn't a neat way to make PRs from PRs, unless you have write access to the repo. And there's honestly still a bunch of open questions we have about tracking open PRs, what commits should be shown/should not be shown by default, etc. Probably @martinvonz or maybe @ilyagr can speak more about this.

Hope this helps.

@martinvonz
Copy link
Member

martinvonz commented Aug 2, 2023

(A bit duplicated with the answer above because I had almost finished before I saw it.)

  • Is it possible to specify the naming with the --change flag?

No. We have talked about doing that but it would require two arguments (for the branch name and the revision), so we're not sure if that means it's better to add a jj git push-branch or something instead of making jj git push's syntax complicated.

  • Or is it possible to specify a template, like <username>/push-xxxxxx, to make it easier to work in a collaborated repo?

Yes, you can set something like push.branch-prefix = "lazywei/push-" in your config file. I'll send a PR to document that in https://github.com/martinvonz/jj/blob/main/docs/config.md

  • Since we need to manually specify the base branch when creating the stack PRs with this method, is it possible to add some sort of ordinal naming like push-42-otznykxnuusx or push-pr42-otznykxnuusx so it's easier to spot out the ordering of multiple created branches / PRs?

Good question. We have #485 about adding more specialized support for setting the base branch in GitHub. Until then - or even after, when pushing a forge we don't support - I would suggest manually naming branches with jj git branch create. Then you can use jj git push -r main..@ or something like that to push all branches in that range of commits. You can use jj log -r main..@ first to verify that it's the range you want.

@arxanas
Copy link
Collaborator

arxanas commented Aug 2, 2023

Not everyone does though! @ilyagr and @arxanas seem to name their branches explicitly.

I would name them automatically, but I don't use jj git and I don't have other automation at present to name the branch for me. I do prefer to prefix the branch with my username (arxanas/<branch>) so that it's associated with me and other tooling can neatly collapse/hide my branches.

@lazywei
Copy link
Author

lazywei commented Aug 2, 2023

Thank you folks, this is really helpful.
I think being able to specify the prefix of branch name is already a good enough solution. Creating the branch name manually and then use jj git push -r main..@ also sounds like a reasonable workaround. I will try this first and see if there is any chance to create some bash/zsh alias to make this less manual.

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 a pull request may close this issue.

4 participants