lindell / multi-gitter

Update multiple repositories in with one command
Apache License 2.0
866 stars 64 forks source link

Feature request: Option to create unique branch name for a given run #486

Open jcmcken opened 3 months ago

jcmcken commented 3 months ago

The feature request

Add some option to generate a randomized branch name by default for a given multi-gitter run (where with each run, the branch name would re-randomize) instead of defaulting to a static value.

My use case

Currently, the branch name defaults to a static value. In a larger team, this can cause conflicts and annoying behavior if users forget to pass the branch name. For example, if one person is trying to update repos A,B, and C, and another person is trying to update B,C, and D. If they forget to pass a unique branch name, they can conflict with one another and lead to a situation where person one succeeds, but person two errors on repo B.

(And as a side note, because of #474, the user might not realize that something has errored if they don't carefully examine the output)

It would be nice if this could be something encoded into the config file that team members can pull in as a default. For example, some option that specifies the branch name as multi-gitter-$(openssl rand -hex 5) (i.e. append a 5 byte hex random string to the end).

For example:

randomize-branch: true

Implementation

lindell commented 3 months ago

Thanks for the suggestions, but I don't know if this is a good idea. At least as suggested. There are two reasons.

  1. You can easily do this externally. (As you suggested -B multi-gitter-$(openssl rand -hex 5))
  2. This might not be the only customization. Users might want to append dates, random strings, name of machine running the script, logged in user, etc... All in different formats.

To solve no.2 we might allow for some pre-defined variables to be used in the branch name. Like -B "branch-name-{random}", but I'm still hesitant.

It feels like the root of your problem is a process problem. Rather than a technical one. Forcing people to use an alias like this one:

alias multi-gitter-run='multi-gitter run -B "multi-gitter-$(openssl rand -hex 5)"'

Might as well solve the problem?

jcmcken commented 3 months ago

I thought about that, although it implies the user needs to set up the alias. I suppose the user would also need to use the correct config file if the option existed. Though the benefit would be installing a single config file vs installing a config file and having to edit a bashrc

Another thought I had was to allow environment variable interpolation the config file. Then you could set the branch name to multi-gitter-$USER (or some other env var unique to the user). But I'm not sure if that's too cute. Though as a benefit, it would allow other types of configuration through the environment as well