Skip to content

Instantly share code, notes, and snippets.

@masaki masaki/gist:78645
Created Mar 13, 2009

Embed
What would you like to do?
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
You can’t perform that action at this time.