0

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
EncryptedWatermelon
  • 4,788
  • 1
  • 12
  • 28

1 Answers1

1

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
Emma
  • 27,428
  • 11
  • 44
  • 69
  • 1
    Interesting. I put your regex in another tester and it doesn't match on `D/foo`. I haven't run it in `svn2git` yet but I suspect it won't work because it works on matching and the branch line works on substitution. http://www.regexe.com/ – EncryptedWatermelon Apr 26 '19 at 12:57
  • 1
    Is it possible to do substation without a pool or dictionary? I found some info here: https://www.rexegg.com/regex-trick-conditional-replacement.html – EncryptedWatermelon Apr 26 '19 at 14:00