summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-27 20:43:08 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-27 20:43:08 (GMT)
commit983d10e0609175a26675a97129b9e7def18d5f35 (patch)
treed1a5a6662edf4c3b4d213a186eff959922f0f04d /tools
parentd4c5730464ea7f9e701ebd5e57f1ac021d7500c6 (diff)
downloadmonitoring-plugins-983d10e0609175a26675a97129b9e7def18d5f35.tar.gz
Remove tools/git2svn.pl
We no longer mirror out Git repositories into Subversion.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/git2svn.pl129
1 files changed, 0 insertions, 129 deletions
diff --git a/tools/git2svn.pl b/tools/git2svn.pl
deleted file mode 100755
index afe2b3b..0000000
--- a/tools/git2svn.pl
+++ /dev/null
@@ -1,129 +0,0 @@
1#!/usr/bin/perl
2#
3# This script pulls the current branch, then walks the first parents and
4# commit each of them into subversion.
5#
6# Copyright (C) 2008 Thomas Guyot-Sionnest <dermoth@aei.ca>
7#
8# The subversion repository must not be taking any external commit or this
9# script will erase them. This script cannot run off a bare repository.
10#
11# *** INITIAL SETUP ***
12#
13# 1. Run this command line to get the repository up and ready for this script:
14#
15# $ cd /path/to/repo/; git log -1 --pretty=format:%H >.git/git2svn.last_commit_hash
16#
17# 2. Configure the lines below... $ENV{'GIT_DIR'} must point to the .git
18# directory of the git-svn repo.
19#
20# *** INITIAL SETUP ***
21#
22# This program is free software: you can redistribute it and/or modify
23# it under the terms of the GNU General Public License as published by
24# the Free Software Foundation, either version 3 of the License, or
25# (at your option) any later version.
26#
27# This program is distributed in the hope that it will be useful,
28# but WITHOUT ANY WARRANTY; without even the implied warranty of
29# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30# GNU General Public License for more details.
31#
32# You should have received a copy of the GNU General Public License
33# along with this program. If not, see <http://www.gnu.org/licenses/>.
34
35use strict;
36use warnings;
37
38# This is the git working tree. Must be tied to a SVN repository
39$ENV{'GIT_DIR'} = '/path/to/nagiosplug/.git';
40
41# For some strange reasons this is needed:
42$ENV{'GIT_SVN_ID'} = 'trunk';
43
44# Path to git binary
45my $git = '/usr/bin/git';
46
47# Force commits from the hash stored in git2svn.last_commit_hash regardless
48# of the state of the current repository. Use this if the repository was
49# updated manually or if you need to set that hash to a specific value.
50# NB: Re-committing old hashes will revert then roll again changes to SVN.
51my $FORCE = 0;
52
53# Print debug output. Useful if you want to see what's being committed.
54my $DEBUG = 0;
55
56for (@ARGV) {
57 $FORCE = 1 if (m/force/);
58 $DEBUG = 1 if (m/debug/);
59 if (m/help/ || m/--help/ || m/-h/) {
60 print "Usage: $0 [ debug ] [ force ] [ help ]\n";
61 exit 0;
62 }
63}
64
65# 1st get the current commit hash - we'll start committing to SVN from this one
66print "Reading saved hash from $ENV{'GIT_DIR'}/git2svn.last_commit_hash\n" if ($DEBUG);
67open(SAVHASH, "<$ENV{'GIT_DIR'}/git2svn.last_commit_hash")
68 or die("Can't open $ENV{'GIT_DIR'}/git2svn.last_commit_hash: $!");
69my $saved_commit_hash = <SAVHASH>;
70chomp $saved_commit_hash;
71print "Saved commit hash: $saved_commit_hash\n" if ($DEBUG);
72close(SAVHASH);
73
74my $last_commit_hash;
75if ($FORCE) {
76 $last_commit_hash = $saved_commit_hash;
77 print "Forcing last commit hash to $last_commit_hash\n" if ($DEBUG);
78} else {
79 print "Running: $git log -1 --pretty=format:%H\n" if ($DEBUG);
80 $last_commit_hash = `$git log -1 --pretty=format:%H`;
81 die("Failed to retrieve last commit hash") if ($?);
82 chomp $last_commit_hash;
83 print "Last commit hash: $last_commit_hash\n" if ($DEBUG);
84
85 # Sanity check
86 die("Last commit hash and saved commit hash don't match, aborting")
87 if ($last_commit_hash ne $saved_commit_hash);
88}
89
90# 2nd pull the remote tree
91print "Running: $git pull\n" if ($DEBUG);
92`$git pull`;
93die("Failed to pull") if ($?);
94
95# Then list all first parents since the last one and insert them into an array
96my @commits;
97print "Running: $git rev-list --first-parent $last_commit_hash..HEAD\n" if ($DEBUG);
98open(REVLIST, "$git rev-list --first-parent $last_commit_hash..HEAD|")
99 or die("Failed to retrieve revision list: $!");
100
101while (<REVLIST>) {
102 chomp;
103 unshift @commits, $_;
104 print "Prepending the list with $_\n" if ($DEBUG);
105}
106
107close(REVLIST);
108
109if (@commits == 0) {
110 print "Nothing to do.\n";
111 exit 0;
112}
113
114# Finally, commit every revision found into SVN
115foreach my $commit (@commits) {
116 print "Commiting $commit to Subversion\n";
117 print "Running: $git svn set-tree --add-author-from $commit\n" if ($DEBUG);
118 `$git svn set-tree --add-author-from $commit`;
119 die("Failed to commit hash $commit") if ($?);
120}
121
122# Once done, update the last commit hash
123$last_commit_hash = pop @commits;
124print "Writing last commit hash to $ENV{'GIT_DIR'}/git2svn.last_commit_hash\n" if ($DEBUG);
125open(SAVHASH, ">$ENV{'GIT_DIR'}/git2svn.last_commit_hash")
126 or die("Can't open $ENV{'GIT_DIR'}/git2svn.last_commit_hash for writing: $!");
127print SAVHASH $last_commit_hash;
128close(SAVHASH);
129