-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-all.pl
101 lines (73 loc) · 2.46 KB
/
update-all.pl
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/perl -w
# Script to pull the main Bugzilla repository, and all associated
# extensions.
use strict;
use Cwd;
my @extensions = ('BayotBase','Dashboard','EnhancedTreeView','InlineEditor','ChangeLog','EnhancedSeeAlso','MediaInfo','ListComponents','Scrums');
sub move_hook_to_extension($){
my ($extension) = @_;
# Put a Git pre-commit hook into place, to ensure perltidy is run.
if (-d "./extensions/$extension/.git"){
`cp pre-commit.extension ./extensions/$extension/.git/hooks/pre-commit`;
`chmod +x ./extensions/$extension/.git/hooks/pre-commit`;
}
}
if (-d "extensions"){
print "Updating repositories:\n";
print " * Pulling ./\n";
`git pull`;
# Put a Git pre-commit hook into place, to ensure perltidy is run.
`cp pre-commit.nwp ./.git/hooks/pre-commit`;
`chmod +x ./.git/hooks/pre-commit`;
my $branch = `git name-rev --name-only HEAD`;
chomp($branch);
# Clone / pull each extension and checkout the current branch.
foreach my $extension (sort @extensions){
if (-d "./extensions/$extension"){
print " * Pulling ./extensions/$extension\n";
chdir("./extensions/$extension");
`git pull`;
chdir("../../");
move_hook_to_extension($extension);
}
else {
print "* Cloning ./extensions/$extension\n";
my $path = "bayoteers/$extension".'.git';
my $cmd = "git clone https://github.com/$path extensions/$extension";
print $cmd."\n";
`$cmd`;
chdir("./extensions/$extension");
my $g_branch;
if ($branch eq 'sandbox'){
$g_branch = 'devel'
}
else{
$g_branch = 'master';
}
`git checkout $g_branch`;
chdir("../../");
move_hook_to_extension($extension);
}
}
# Make sure we have all the latest schema updates
# and any new parameters.
`sudo rm data/templates -rf`;
print "Running checksetup.pl\n";
`perl checksetup.pl`;
# Run the basic unit tests that come with Bugzilla.
print "Running runtests.pl\n";
`perl runtests.pl`;
# Put .perltidyrc into place to ensure consistent Perl code.
print "Putting perltidyrc into place\n";
if (-f "~/.perltidyrc"){
my $result = `diff -q perltidyrc ~/.perltidyrc`;
if ($result){
print "Backing up existing ~/.perltidyrc to ~/.perltidyrc.bak\n";
`cp ~/.perltidyrc ~/.perltidyrc.bak`;
}
}
`cp ./perltidyrc ~/.perltidyrc`;
}
else {
die("Can't find 'extensions' folder");
}