summaryrefslogtreecommitdiff
path: root/src/mozclient/lib/MozClient/Git.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/mozclient/lib/MozClient/Git.pm')
-rw-r--r--src/mozclient/lib/MozClient/Git.pm100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/mozclient/lib/MozClient/Git.pm b/src/mozclient/lib/MozClient/Git.pm
new file mode 100644
index 0000000..393032b
--- /dev/null
+++ b/src/mozclient/lib/MozClient/Git.pm
@@ -0,0 +1,100 @@
+# -*- mode: Perl -*-
+
+# Copyright (c) 2007-2008 Fabien Tassin <fta@sofaraway.org>
+# Description: MozClient::Git
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2, or (at
+# your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+############################################################################
+
+package MozClient::Git;
+
+use vars qw(@ISA);
+use strict;
+use MozClient::VCS;
+
+@ISA = ("MozClient::VCS");
+
+sub get_client {
+ my $self = shift;
+
+ $self->LOG("MozClient::Git::get_client()");
+ # nothing to do
+}
+
+sub convert_revdate {
+ my $self = shift;
+ my $arg = shift;
+
+ $self->LOG("MozClient::Git::convert_revdate($arg)");
+ $arg =~ s,^\d+r,,;
+ $arg;
+}
+
+sub set_revdate {
+ my $self = shift;
+
+ $self->LOG("MozClient::Git::set_revdate()");
+
+ # We can set a revision for git
+ $self->{'mozclient_date'} =
+ $self->convert_revdate($self->{'have_date'});
+}
+
+sub set_tag {
+ my $self = shift;
+ my $tag = shift;
+
+ $self->LOG("MozClient::Git::set_tag($tag)");
+
+ $self->{'co_tag'} = "$tag";
+}
+
+sub checkout {
+ my $self = shift;
+
+ $self->LOG("MozClient:Git::checkout:()");
+ $self->chdir($self->work_dir);
+ my $modules = [];
+ if (defined $self->{'MOZCLIENT_PROJECT'}) {
+ push @$modules,
+ $self->{'MOZCLIENT_VCS_LOC'} . $self->{'MOZCLIENT_PROJECT'} . "/";
+ }
+ else {
+ warn "MOZCLIENT_MODULES not supported for Git";
+ for my $module (@{$self->{'MOZCLIENT_MODULES'}}) {
+ push @$modules, (sprintf " %s%s/%s", $self->{'MOZCLIENT_VCS_LOC'},
+ $self->{'MOZCLIENT_PROJECT'}, $module);
+ }
+ }
+ my $cmd = sprintf "git clone %s %s", join(" ", @$modules), $self->{'MOZCLIENT_MOZDIRNAME'};
+ $self->run_system($cmd);
+ $self->chdir($self->{'MOZCLIENT_MOZDIRNAME'});
+ my $rev = $self->{'mozclient_date'} ? $self->{'mozclient_date'} : $self->{'co_tag'};
+ $cmd = sprintf "git branch %s %s", $rev, $rev;
+ $self->run_system($cmd);
+ $cmd = sprintf "git checkout %s", $rev;
+ $self->run_system($cmd);
+ $self->chdir("../..");
+}
+
+sub tar_exclude {
+ my $self = shift;
+
+ $self->LOG("MozClient::Git::tar_exclude()");
+ [ '--exclude .git', '--exclude .gitignore' ];
+}
+
+1;