git-repo-sync icon indicating copy to clipboard operation
git-repo-sync copied to clipboard

Define multible branch prefixes and conventional strategie only

Open heavySea opened this issue 3 years ago • 8 comments

First of all, thank you for this helpfull tool!

In our use-case we want to synchronise a local copy of a customers fairly large git. For this we only want to synchronize a few branches. But these do not have a common prefix.

Is it possible, that you define multiple branch names/prefixes?

Moreover is it possible to select the conventional conflict solving strategie only and as default? For now it seem, that you have to set a branch in victim_branches_prefix or the whole repository is synced.

Thank you in advance.

heavySea avatar Oct 19 '22 08:10 heavySea

Hello @heavySea, good questions, thank you.

I need some time to remember. So my answers won't be accurate now. But I'll give them right now.

it3xl avatar Oct 19 '22 11:10 it3xl

Synchronization of few none prefixed branches in a single project.

Workaround

Could you use multiple projects for the same pair of remote repositories? For example. In one project it will be

url_a=https://example.com/git/my_repo.git
#
url_b='/c/my-folder/my-local-git-repo-folder'

side_a_conventional_branches_prefix=one-branch

In another project

url_a=https://example.com/git/my_repo.git
#
url_b='/c/my-folder/my-local-git-repo-folder'

side_a_conventional_branches_prefix=branch-for-a-feature

etc. But this will continue to behave like a prefixes. So if you have the following branches

  • one-branch
  • one-branch-2

the both will be synchronized for side_a_conventional_branches_prefix=one-branch configuration.

Yes, this is stupid, I understand. Also, it will give you some storage and network overhead.

Solution

First of all, I can't imagine how to configure it conveniently.

  • We have prefixes now.
  • We will be having list of branches.
  • How to separate those branch names?
  • Use additional variables? OK. But how to be if I'll add another sync strategy later? OK, analyze and parse a bunch of configuration.
  • Put everything in the existing variables? How? How to parse everything. Branches and prefixes separately.

So, you see. Configuration, documentation, development and testing will grow. :)

it3xl avatar Oct 19 '22 12:10 it3xl

Disable the Victim Conflict Solving

Workaround

Use something like this in your project configuration.

victim_branches_prefix=abracadabra

or

victim_branches_prefix=we-do-not-use-victim-conflict-solving-@@@

Solution

I could add an additional parameter later. Right! Or propose another solution, please.

it3xl avatar Oct 19 '22 12:10 it3xl

And @heavySea, sorry for inconveniences.

it3xl avatar Oct 19 '22 12:10 it3xl

Hello @it3xl, thank you for your fast response and suggestions.

  1. Using multiple sync-projects for the same repository sites.

Yes we already thought of this workaround. I guess this would work for us at the moment, since we only need to sync a few branches, that have not a common prefix. Though, one drawback is, that it creates local clones of the repository as many times as there are sync-repositories. With large repos this will accumulate quite fast. Nevertheless this is probably the solution we are going to use for now, if needed.

I see your problem with the differentiation between prefix and complete branch names. Maybe you could use the common wildcard symbol '*' to hint that there can be an arbitrary input behind the prefix. For example: 'branchA-' would be a single branch with this name and 'branchA-*' is a prefix so 'branchA-XYZ' is also included.

  1. Disable victim conflict solving

That seems like a fairly hacky workaround, but we are going to test it. Nevertheless it seems quite unintuitive, that leaving victim_branches_prefix unset but not victim_branches_prefix resulting in syncing all branches. It would be more intuitive if either a. both variables are unset, i.a. nothing is filtered or b. use the wildcard symbol '*' again and set either victim_branches_prefix=* or victim_branches_prefix=* to sync all branches either with conventional or victim stategy.

Again I would like to thank you for this tool, which otherwise works very well, and your support.

heavySea avatar Oct 19 '22 12:10 heavySea

The star symbol is allowable to use in Git branch names if REFNAME_REFSPEC_PATTERN is set. AFAIK

it3xl avatar Oct 21 '22 19:10 it3xl

Maybe "~"

it3xl avatar Oct 21 '22 19:10 it3xl

So, if I put everything in the existing variables and created a single parsing logic this will be good. Many thanks.

it3xl avatar Oct 21 '22 19:10 it3xl