Created
May 8, 2015 00:23
-
-
Save memememomo/c0907e0c23ba134dd734 to your computer and use it in GitHub Desktop.
git-script
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
#------------------------------ | |
# gitflowのショートカットシェルスクリプトを生成する | |
#------------------------------ | |
use strict; | |
use warnings; | |
my $dir = $ARGV[0]; | |
if (!$dir) { | |
die "出力先ディレクトリを指定してください。\n$0 {directory}\n"; | |
} | |
if (! -d $dir) { | |
die "ディレクトリではありません。: $dir\n"; | |
} | |
if (! -w $dir) { | |
die "このディレクトリに書き込めません。: $dir\n"; | |
} | |
my $filename = ''; | |
my $buf = ''; | |
while (my $line = <DATA>) { | |
if ($line =~ /^\-\-\-(.+)/) { | |
my $f = $1; | |
if ($filename && $buf) { | |
generate_file($filename, $buf); | |
} | |
$filename = $f; | |
$buf = ''; | |
} | |
else { | |
$buf .= $line; | |
} | |
} | |
if ($filename && $buf) { | |
generate_file($filename, $buf); | |
} | |
sub generate_file { | |
my ($filename, $buf) = @_; | |
my $path = "$dir/$filename"; | |
open my $fh, '>', $path or die "Can't open: $path"; | |
print $fh $buf; | |
close $fh; | |
chmod 0755, $path; | |
print "creating $path\n"; | |
} | |
__DATA__ | |
---gallpush | |
#!/bin/sh | |
git push --tags; | |
git push origin master | |
git push origin develop | |
---gallpull | |
#!/bin/sh | |
git fetch --tags | |
git checkout master && git pull origin master | |
git checkout develop && git pull origin develop | |
git branch | |
---gfeature-start | |
#!/bin/sh | |
if [ -z $1 ]; then | |
echo "Usage: $0 {feature-name}" | |
exit; | |
fi | |
git flow feature start $1 | |
---gfeature-finish | |
#!/bin/sh | |
if [ -z $1 ]; then | |
echo "Usage: $0 {feature-name}" | |
exit; | |
fi | |
git flow feature finish $1 | |
---ghotfix-start | |
#!/bin/bash | |
now=`date "+%Y%m%d%H%I%M%S"` | |
if [ -z $1 ]; then | |
git tag | |
echo "------------------------" | |
echo "Usage: $0 {major-number}" | |
exit; | |
fi | |
git flow hotfix start $1.$now | |
---ghotfix-finish | |
#!/bin/sh | |
branch=$1 | |
if [ -z $branch ]; then | |
for b in $(git for-each-ref --format='%(refname:short)' refs/heads); do | |
if expr $b : "hotfix/" > /dev/null; then | |
branch=`echo $b | sed "s/hotfix\///g"`; | |
fi | |
done | |
if [ -z $branch ]; then | |
echo "Usage: $0 {hotfix-name}" | |
exit; | |
fi | |
fi | |
echo "finish hotfix/$branch OK?(y/N)" | |
read ans | |
if [ "$ans" != "y" ]; then | |
exit; | |
fi | |
git flow hotfix finish $branch | |
---grelease-start | |
#!/bin/sh | |
if [ -z $1 ]; then | |
git tag | |
echo "------------------------" | |
echo "Usage: $0 {major-number}" | |
exit; | |
fi | |
git flow release start $1 | |
---grelease-finish | |
#!/bin/sh | |
if [ -z $1 ]; then | |
echo "Usage: $0 {major-number}" | |
exit; | |
fi | |
git flow release finish $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment