Last active
September 28, 2015 10:09
-
-
Save dogmatic69/1422991 to your computer and use it in GitHub Desktop.
After running git svn clone, handy little script that will create all the correct branches and tags for the repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/php5 | |
| <?php | |
| $branches = array_filter(explode("\n", `git branch -r`)); | |
| `clear`; | |
| foreach((array)$branches as $branch) { | |
| echo sprintf("Working on %s\n======================================\n\n", $branch); | |
| $commands = array(); | |
| $branch = trim($branch); | |
| if(empty($branch)) { | |
| continue; | |
| } | |
| $tagName = str_replace('tags/', '', $branch); | |
| $branchLocal = $branch . '-svn'; | |
| $commands[] = "git checkout -b $branchLocal remotes/$branch"; | |
| if(strstr($branch, 'tags/')) { | |
| echo sprintf("Creating tag '%s' from branch 'remotes/%s'\n", $tagName, $branch); | |
| $commands[] = "git tag $tagName"; | |
| $commands[] = "git checkout master"; | |
| $commands[] = "git branch -D $branchLocal"; | |
| } else { | |
| $commands[] = "git checkout master"; | |
| } | |
| foreach($commands as $command) { | |
| echo sprintf("Running command: '%s'\n", $command); | |
| `$command`; | |
| } | |
| echo "\n\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment