aboutsummaryrefslogtreecommitdiff
path: root/src/util/git-commit-everything.pl
blob: d97221832eac27482d7954d56d9590e4182db1f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/perl -w

# Commit everything to the repository

# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>

use strict;



$#ARGV == 4 or die;
my ($git_cmd, $git_repo, $git_root, $build_id, $config_id) = @ARGV;

# Path where the git-*.pl commands are installed
my $bindir = $ENV{'SCRATCH_BUILD'} . '/formaline-bin';

my $silent = $ENV{'SILENT'};
$silent = 'yes' if ! defined $silent;
$silent = $silent !~ /^no$/i;
my $silencer = $silent ? '> /dev/null 2>&1' : '';



# Ensure that the repository exists
die unless -e "$git_repo/.git";
$ENV{'GIT_DIR'} = "$git_repo/.git";



print "Formaline: Committing source tree to git repository...\n";

# Try to use the previous commit as parent, if possible
print "Executing: $git_cmd commit -m $build_id\n" unless $silent;
system "$git_cmd commit -m $build_id $silencer";
# Ignore errors
#if ($?) {
#    die "Could not commit";
#}

print "Executing: $git_cmd tag $build_id\n" unless $silent;
system "$git_cmd tag $build_id $silencer";
if ($?) {
    die "Could not tag";
}
print "Formaline: Created git tag $build_id\n";

print "Executing: $git_cmd branch -f $config_id\n" unless $silent;
system "$git_cmd branch -f $config_id $silencer";
if ($?) {
    die "Could not update branch";
}
print "Formaline: Updated git branch $config_id\n";

print "Executing: $bindir/git-gc-repo.pl '$git_cmd' $git_repo\n" unless $silent;
system "$bindir/git-gc-repo.pl '$git_cmd' $git_repo $silencer";
if ($?) {
    die "Could not collect garbage";
}