This repository has been archived by the owner on May 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modify-post-commit.php
70 lines (62 loc) · 2.08 KB
/
modify-post-commit.php
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
<?php
require 'config.php';
if ( !file_exists(SVN_PARENT))
die(SVN_PARENT . " does not exist");
$use_template = true;
$content = "";
if ( isset ( $_POST['repository']) && !empty($_POST['repository'])) {
$path = SVN_PARENT . "/{$_POST['repository']}/hooks/post-commit";
if ( isset ( $_POST['content'] ) ) {
file_put_contents($path, str_replace("\r\n", "\n", $_POST['content']));
system("chmod u+x $path");
}
if ( file_exists($path)) {
$content = file_get_contents($path);
}
if ( $content == "" && $use_template) {
$content = file_get_contents($path . ".tmpl");
}
}
$dp = opendir(SVN_PARENT);
while ( ( $file = readdir($dp)) !== false) {
if ( $file[0] == "." ) continue;
if ( is_dir ( SVN_PARENT ."/$file" ) ) {
$repositories[] = $file;
}
}
closedir($dp);
sort($repositories);
?>
<? include 'layout/header.php'; ?>
<form method="POST">
<label for="repository">Repository:</label>
<select name="repository">
<option></option>
<?php
foreach ( $repositories AS $file) {
if ( $_POST['repository'] == $file ) {
echo "<option selected=\"selected\">$file</option>\n";
} else {
echo "<option>$file</option>\n";
}
}
?>
</select><input type="submit" value="Auswählen" />
</form>
<hr />
<?php if(isset($_POST['repository']) && !empty($_POST['repository'])): ?>
<form method="POST">
<input type="hidden" name="repository" value="<?php echo $_POST['repository']; ?>" />
<span>Repository: <?php echo $_POST['repository']; ?></span><br />
<label for="content">post-commit trigger:</label><br />
<textarea cols="80" rows="20" name="content"><?php print $content; ?></textarea>
<br />
<input type="submit" value="Speichern" />
</form>
<div>
<span class="tipp">
A post-commit hook is a bash script, that gets executed after a commit to the repository has been done. Its called with two arguments: The repository path and the revision of the executed commit.
</span>
</div>
<?php endif; ?>
<? include 'layout/footer.php'; ?>