From c283158cb39dc40b5e12989469e7ed400e538ed6 Mon Sep 17 00:00:00 2001 From: Fabien Tassin Date: Sun, 12 Oct 2008 19:04:41 +0200 Subject: * [mozclient] add support for git - add src/mozclient/lib/MozClient/Git.pm - update src/mozclient/mozclient.pl - update src/mozclient/lib/MozClient/VCS.pm - update debian/control --- src/mozclient/lib/MozClient/Git.pm | 100 +++++++++++++++++++++++++++++++++++++ src/mozclient/lib/MozClient/VCS.pm | 1 + src/mozclient/mozclient.pl | 2 + 3 files changed, 103 insertions(+) create mode 100644 src/mozclient/lib/MozClient/Git.pm (limited to 'src') 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 +# 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; diff --git a/src/mozclient/lib/MozClient/VCS.pm b/src/mozclient/lib/MozClient/VCS.pm index 79e5ba1..f5b1b56 100644 --- a/src/mozclient/lib/MozClient/VCS.pm +++ b/src/mozclient/lib/MozClient/VCS.pm @@ -34,6 +34,7 @@ my $nobinonly = "nobinonly"; my $dependencies = { 'cvs' => '/usr/bin/cvs', 'mercurial' => '/usr/bin/hg', + 'git' => '/usr/bin/git', 'quilt' => '/usr/bin/quilt', 'wget' => '/usr/bin/wget', }; diff --git a/src/mozclient/mozclient.pl b/src/mozclient/mozclient.pl index e909ae0..d106231 100755 --- a/src/mozclient/mozclient.pl +++ b/src/mozclient/mozclient.pl @@ -175,6 +175,7 @@ sub read_project_file { use MozClient::CVS; use MozClient::Mercurial; use MozClient::Subversion; +use MozClient::Git; # Main my $opt = {}; @@ -198,6 +199,7 @@ my $vcs = $$conf{'MOZCLIENT_VCS'}; $vcs eq 'cvs' && do { $client = MozClient::CVS->new($conf, $opt); 1; } || $vcs eq 'svn' && do { $client = MozClient::Subversion->new($conf, $opt); 1; } || $vcs eq 'hg' && do { $client = MozClient::Mercurial->new($conf, $opt); 1; } || +$vcs eq 'git' && do { $client = MozClient::Git->new($conf, $opt); 1; } || do { die "VCS '$$conf{'MOZCLIENT_VCS'}' not supported yet"; }; -- cgit v1.2.3