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

Mecanism for excluding branches from the octopus #14

Open
apflieger opened this issue Jul 15, 2016 · 6 comments
Open

Mecanism for excluding branches from the octopus #14

apflieger opened this issue Jul 15, 2016 · 6 comments

Comments

@apflieger
Copy link
Contributor

apflieger commented Jul 15, 2016

Usecases :

  1. In some configuration, all branches of a repo are merged in a octopus. For instance, having multiple repos, one of them called 'features', is a good practice. The resulting merge of the 'features' repo can't be pushed on the repo itself because it would be taken itself in a subsequent octopus merge. The workaround is to push the merge on a separate repo (this is what LesFuets.com does).
  2. A developper pushed his branch and broke the octopus merge. He tries to fix it on his local repo. To do so, he commits changes on his local branch and run git octopus locally to test if it fixes the merge. The problem is that this local octopus will include the remote branch as well as the local one, which causes conflicts in most cases. The only workaround we have currently is to delete the remote branch locally with git update-ref -d refs/remotes/origin/branch_name before running the local octopus.

In both cases, we just need to exclude a given branch from the merge. We need to consider both usecases for finding an elegant solution.

I came up with some ideas. First thing is that in both cases, we would expect the exclusion to be done everytime the command is run. So it should be declarable in configuration.

Proposal:

  1. Allow a new syntax that negate branch pattern : !branche-to-exclude or even !branch-*. This would work as both command argument and configuration entry.

  2. Allow git octopus to detect and exclude automatically the remote branch that correspond to the local branch you are on. This behavior itself should be configurable (conf key octopus.exclude) with the following values :

    • none (default): don't detect the remote branch
    • current: exclude branches that have the same name that the current local branch
    • upstream: read the upstream configuration of the current local branch. I'm not sure if this value is needed but maybe just for consistency/transparency on how it works internally.
    • pushDefault: automatically choose between none, current and upstream depending on the value of the push.default config (see git-config push.default section). This could be the default value on the next major release of git-octopus. Here's the mapping between push.default values and the resulting remote detection:
      • nothing : none
      • current : current
      • upstream : upstream
      • simple : current or upstream. The latter is the safest because it will match the remote part of the ref which is not possible in the current mode. See bellow.
      • matching : I'm not sure, probably none

    We need to choose the behavior of the current value regarding remotes. git push uses the notion of 'remote' whereas git octopus doesn't. This means that in the current mode, we are not able to determine the remote part of the ref (of the remote branch we are looking for) in the context of a git octopus run. I don't think it is a big deal, let's just trip off refs/heads/ of the current branch ref, grep it on the list of branches beeing merged and exclude the result.

Note that 1. and 2. could be implemented seperately

@apflieger
Copy link
Contributor Author

@benba @geofberard It's a bit dense, sorry for that. Tell me if there's anything not clear or missing. It's an opened discussion of course.

@benba
Copy link
Contributor

benba commented Jul 23, 2016

Seems great to me , it's much more elaborated than what I had in mind :-)
For the syntax to exclude I would suggest something like -e pattern instead of !branch-to-exclude because branch can be created with a leading !
ex: git octopus -e octopus-* -e master features/*
A very straight forward implementation would be to git ls-remote the matching pattern as today
then git ls-remote with all exclude patterns
and then retain only branches that are not in the intersection of both lists.
The advantage is than the pattern syntax would be exactly the same between the include part and the exclude part.

@apflieger
Copy link
Contributor Author

How do we deal with the config then ? It seems that we'll have to introduce a new config key like octopus.excludePattern

@ozangunalp
Copy link
Contributor

@benba @apflieger I've a modification which does exactly that. With -e option and octopus.excludePattern config key. I'll try to clean up the code and make a PR.

And @apflieger +1 for detecting automatically the branch to exclude

@apflieger
Copy link
Contributor Author

Hi @ozangunalp, we haven't met yet!
This would be welcome.

@apflieger
Copy link
Contributor Author

Update : the first part is in the master branch and will be part of the next release (1.4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants