Skip to content

Instantly share code, notes, and snippets.

@memememomo
Created May 8, 2015 00:23
Show Gist options
  • Save memememomo/c0907e0c23ba134dd734 to your computer and use it in GitHub Desktop.
Save memememomo/c0907e0c23ba134dd734 to your computer and use it in GitHub Desktop.
git-script
#------------------------------
# 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