Created
July 28, 2017 20:41
-
-
Save blendsdk/5e313a9988aa502223b457ee109580fb to your computer and use it in GitHub Desktop.
This file contains 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/php | |
<?php | |
if(count($argv) !== 2) { | |
die("Need a new branch name\n"); | |
} | |
$info = pathinfo($argv[0]); | |
$command = str_replace("git-","",$info["basename"]); | |
$new_branch = str_replace(array(' ',"\\","\"","\t","\n","\r","-"),'-',$argv[1]); | |
$current_branch=trim(`git symbolic-ref --short HEAD 2>/dev/null`); | |
$configFile=getenv("HOME")."/.custom-git-config"; | |
$config = array(); | |
if($current_branch !== "devel" && $current_branch !== "master") { | |
die("You are not on devel or master branch\n"); | |
} | |
if(file_exists($configFile)) { | |
$config = json_decode(file_get_contents($configFile),true); | |
} | |
if(!isset($config[$command])) { | |
$config[$command] = 100; | |
} else { | |
$config[$command] = $config[$command] + 1; | |
} | |
$branch_name = "$command/{$config[$command]}-{$new_branch}"; | |
file_put_contents($configFile,json_encode($config)); | |
`git checkout -b "$branch_name"`; | |
echo(`git branch -l`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment