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

Allow Regex and/or Globbing for the testing branch #72

Open
fkonradmain opened this issue Mar 27, 2025 · 1 comment
Open

Allow Regex and/or Globbing for the testing branch #72

fkonradmain opened this issue Mar 27, 2025 · 1 comment

Comments

@fkonradmain
Copy link

Per default, comin searches for the main branch, defined via services.comin.remotes.*.branches.main.name (default main) and for a specific feature branch called testing-${config.services.comin.hostname}, defined via services.comin.remotes.*.branches.testing.name.

When developing with merge requests, usually we do not want to use the same feature branch twice. If at this point, we want to use a differently named feature branches, we first have to commit the feature branch name to this host's main. Only then can we start developing on that branch.

Only then can we start developing on the feature branch and use the testing branch feature.

To ease this process, I would like to introduce another option called services.comin.remotes.*.branches.testing.nameRegex or services.comin.remotes.*.branches.testing.nameGlob (or both).

With that, we can define a pattern for all future feature branches.

In that case, a user could define their flake e.g. as:

{
  inputs = {
    nixpkgs.url = "github:nixOS/nixpkgs";
    comin = {
      url = "github:nlewo/comin";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = { self, nixpkgs, comin }: {
    nixosConfigurations = {
      myMachine = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          comin.nixosModules.comin
          ({config, ...}: {
            services.comin = {
              enable = true;
              remotes = [{
                name = "origin";
                url = "https://gitlab.com/your/infra.git";
                branches.main.name = "main";
                branches.testing.nameRegex = "(feat|fix|testing|foo)/${config.services.comin.hostname}/.*"
              }];
            };
          })
        ];
      };
    };
  };
}

With that, the user could then create feature branches like testing/myMachine/new-feature-a fix/myMachine/bug-in-service-xy.

With that, a new question arises though: A branch selection algorithm.

As long as only a single feature branch exists at a time, there should not be any issues. That is because comin only accepts feature branches that are based on the current main HEAD.

If two branches follow that pattern, we could:

a) throw an error and exit
b) use the branch that matches first alphabetically
c) use the branch that has the most recent changes

Before I start testing and developing such a feature, I would like to ask, if this idea is acceptable. Thank you very much.

@nlewo
Copy link
Owner

nlewo commented Apr 2, 2025

I'm not convinced this could be easily used since it would be really hard to know on which branch your machine is. I also think it's a bit risky to let your machine switching between branches when you submit PRs.
Moreover, this would make the comin implementation more complex, for a specific use case.

So, i'm currently not in favor of this feature but we could let this issue open to see what other people think about it.

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

No branches or pull requests

2 participants