Search code examples
regexsvn2git

svn2git rules regex


I'm trying to reduce my ruleset for svn2git. My tree looks like this..

A/foo
B/foo
C/foo
D/foo

I want to put A, B, and C under a legacy folder and that works. I want D to be it's own top level folder.

My current rule is..

match /(A|B|C)/([^/]+)/
  repository myrepo
  branch legacy/\1/\2
end match

Is it possible to modify the rule such that D does not end up legacy without having to define another rule?

End result should be:

legacy/A/foo
legacy/B/foo
legacy/C/foo
D/foo

Solution

  • Yes, it is possible. I'm not sure how svn2git RegEx might look like. However, this RegEx might create your outputs by simply keeping D/foo as is, and then only changing your other three inputs using two groups plus a middle boundary /:

    ^(A|B|C)\/(foo)
    

    enter image description here

    You can probably change your codes based on this RegEx.

    I'm not really sure, but my guess is that you codes might change to something similar to:

    match /^(A|B|C)\/(foo)/
      repository myrepo
      branch legacy/\1/\2
    end match
    

    It the code would work, it would probably work without ^:

    match /(A|B|C)\/(foo)/
      repository myrepo
      branch legacy/\1/\2
    end match