Automatically sync feature branches?

My team is evaluating Git X-Modules (for Github) and so far it’s very promising! There is one aspect that I have not been able to figure out and seems to be missing in documentation.

What I’d like to do is set up a rule so that when a branch on the parent repo is created matching feature/* then it will be synced with a branch on each module repo with the pattern feature/{1} (create them if they don’t exist).

It seems like this a use-case for the “advanced branch rules” feature but when new branches are created on the parent repo, they don’t inherit any rules and have to be set up individually. If this is the case, what is the purpose of wildcards in the branch rules?

Hi Jeremy,

Thanks for giving Git X-Modules a try and sharing your experience with us.

It seems like this a use-case for the “advanced branch rules” feature but when new branches are created on the parent repo, they don’t inherit any rules and have to be set up individually. If this is the case, what is the purpose of wildcards in the branch rules?

Right, we’ve introduced the branch rules editor just recently and there are some quirks with that feature, indeed.

When you add a new rule feature/*:feature/{1} to the branch main, this rule is effective to none of existing commits, it only gets applied to the ref main:

refs/heads/main [main:main, feature/*:feature/{1}]
|
* B [main:main]
|
* A [main:main]

Then, when the branch main fetches any changes from any modules, a new commit appears and this commit has the new rule:

refs/heads/main [main:main, feature/*:feature/{1}]
|
* C [main:main, feature/*:feature/{1}]
|
* B [main:main]
|
* A [main:main]

At this point you can create a branch feature/x on commit C or on any commit that has C as an ancestor. Then the branch feature/x gets synchronized with the branch feature/x in the corresponding module:

refs/heads/feature/x [main:main, feature/*:feature/{1}]
|
* D [main:main, feature/*:feature/{1}]
|
* C [main:main, feature/*:feature/{1}]
|
* B [main:main]
|
* A [main:main]

So, in order to make the rule feature/*:feature/{1} effective you’d need to make Git X-Modules fetch anything from any module on the branch main.

We do want to change that behavior: we’re going to introduce .xmodules file that stores information on all the x-modules within a commit file tree. So, when you add a new rule feature/*:feature/{1}, we’re going to generate a new commit with a new .xmodules file that has the new branch rule:

 [module "xyz"]
     url = https://github.com/org/repo
     path = modules/xyz
     ref = if refs/heads/main sync refs/heads/main
+    ref = if refs/heads/feature/* sync refs/heads/feature/{1}

That automatically gets rid of the problem as adding any new branch rule automatically generates a commit with the new rule being effective. Unfortunately, we’re quite limited resource-wise at the moment, so it’s hard to estimate when we’re able to introduce .xmodules file descriptor support.

I’d also like to mention a couple of things that we’re not going to change with the next releases:

  • Note that the older commits A and B still don’t have the new rule, the branch rules get applied to new commits only.

  • Also, note that if you have some other branches, e.g. develop you might need to add new branch rules to those branches as well.

Hopefully, that’s fine for your workflow, please let me know if any of those two points cause any problems for your team.

Finally, I’d like to mention that we’re running a survey on typical problems that our product helps to solve. It would be tremendously helpful for us if you could fill the form (it takes 5-10 minutes): https://forms.gle/wzCLoUDr8Jb937mw7

Thank you in advance!

Ah, thanks for the details response! After posting, I did see the rules apply to a feature branch but wasn’t sure exactly how that happened. I think that having the rules contained in .xmodules files would be extremely helpful and make the rules much easier to understand and use.

I’m not sure why I’m seeing the following behavior:

  1. I create a feature/monorepo-test branch in a module and make a commit to it and push.
  2. I create a branch with the same name in my parent repo.
  3. I see the feature branch rule is picked up and shown in the UI

    However, when commits are pushed to the module branch, they are not synced to the parent.
  1. I update the rules in the UI to not use the advanced mode and just select the branch
    Screen Shot 2022-12-21 at 5.18.32 PM
    (Note: there is some UI glitch and I have to select the branch twice)
  2. After applying the changes, the module commits now appear in my parent branch

Is this a bug or am I missing something? Thanks!

Right, that’s a bug, I’ve just managed to reproduce this problem. I’ll try to fix that as soon as possible and will let you know when the fix is available for you to try.

Thank you for reporting that!

1 Like

@Jeremy,

Thank you so much for providing the feedback on Git X-Modules.

We’ve just deployed a new version of the app that fixes the problem you’ve reported. Please give it a try and let us know how this version works for you. Thanks!

Awesome, thank you!! I have verified the fix is working and the feature branches are syncing as expected.