aboutsummaryrefslogtreecommitdiff
path: root/src/util/git-commit-everything.pl
blob: 498342adcc7e66e218463c7c0d6eb9d6d855cc73 (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
59
60
61
62
63
#! /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";

# Invent a user id if there is none, since newer versions of git
# insist on it
system "$git_cmd config user.name > /dev/null 2>&1 || $git_cmd config user.name \"\${USER}\" $silencer";
system "$git_cmd config user.email > /dev/null 2>&1 || $git_cmd config user.email \"\${USER}\@localhost\" $silencer";

# 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\nCommand was\n   $git_cmd tag '$build_id'";
}
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\nCommand was\n   $git_cmd branch -f '$config_id'";
}
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\nCommand was\n   '$bindir/git-gc-repo.pl' '$git_cmd' '$git_repo'";
}