Skip to content

Instantly share code, notes, and snippets.

@masaki
Created March 13, 2009 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masaki/78645 to your computer and use it in GitHub Desktop.
Save masaki/78645 to your computer and use it in GitHub Desktop.
ShipIt with Git
diff --git a/lib/ShipIt/VC/Git.pm b/lib/ShipIt/VC/Git.pm
index 9bf21d7..b5b6c2c 100644
--- a/lib/ShipIt/VC/Git.pm
+++ b/lib/ShipIt/VC/Git.pm
@@ -61,6 +61,18 @@ sub commit {
print $tmp_fh $msg;
my $tmp_fn = "$tmp_fh";
system($command, "commit", "-a", "-F", $tmp_fn);
+
+ if (my $where = $self->{push_to}) {
+ open my $fh, '<', '.git/HEAD';
+ chomp(my $head = do { local $/; <$fh> });
+ close $fh;
+
+ my ($branch) = $head =~ m!ref: refs/heads/(\S+)!;
+ if ($branch) {
+ warn "pushing to $where";
+ system($self->command, "push", $where, $branch);
+ }
+ }
}
sub local_diff {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment