aboutsummaryrefslogtreecommitdiff
path: root/src/util/git-init-local-repo.pl
blob: d9b7db91ac540129823e8e6fe05c0f3854946e35 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/perl -w

# Initialise the local repository

# 2011-11-13 Erik Schnetter <eschnetter@perimeterinstitute.ca>

use strict;



$#ARGV == 1 or die;
my ($git_cmd, $git_local_repo) = @ARGV;

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



# If the repository exists already, do nothing
if (-e "$git_local_repo/.git") {
    exit;
}



print "Formaline: Creating git local repository...\n";

# Create the directory for the repository
mkdir $git_local_repo;
$ENV{'GIT_DIR'} = "$git_local_repo/.git";

# Create the repository
print "Executing: $git_cmd init-db\n" unless $silent;
system "$git_cmd init-db $silencer";
if ($?) {
    die "Formaline: WARNING: Error while initialising local git repository\nCommand was\n   $git_cmd init-db";
}
print "Executing: $git_cmd config receive.denyCurrentBranch false\n" unless $silent;
system "$git_cmd config receive.denyCurrentBranch false $silencer";
if ($?) {
    die "Formaline: Error while configuring local git repository\nCommand was\n   $git_cmd config receive.denyCurrentBranch false";
}



# Add a README
open README, "> $git_local_repo/README" or die;
my $today = `date`;
chomp $today;
print README "\
This directory $git_local_repo
is not empty -- it contains a git repository with the Cactus source
trees of all previous builds, starting on $today.

You can use the command \"git branch\" to list all configurations that
are stored in this repository.  The history of each branch is the
sequence in which the configurations were built.  The most recent
build is stored in the branch head, as usual.  In order to check out a
certain branch into a directory <name>, issue the following commands:
        cd <somewhere_else>
        mkdir <name>
        cd <name>
        git init
        git pull $git_local_repo <branch>

You can also use the command \"git tag -l\" to list all builds that
are stored in this repository.  This keeps the source tree for each
build directly accessible.  In order to check out a certain tag into a
directory <name>, issue the following commands:
        cd <somewhere_else>
        git clone -o <name> $git_local_repo
        git checkout <tag>
"
    or die;
close README or die;