-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtranslate.php
More file actions
54 lines (47 loc) · 1.73 KB
/
translate.php
File metadata and controls
54 lines (47 loc) · 1.73 KB
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
<?php
$revision = "";
$hash = "";
$output = "";
if (isset ($_GET["revision"])) { $revision = filter_var (ltrim ($_GET["revision"], 'r'), FILTER_SANITIZE_NUMBER_INT); }
if (isset ($_GET["hash"])) { $hash = preg_replace ('/[^0-9a-f]/', '', strtolower (trim ($_GET["hash"]))); }
if (isset ($_GET["output"])) { $output = trim ($_GET["output"]); }
$dir = "/home/pencil/translate/";
if ($revision != "") {
# search GIT hash
$update = `cd "$dir" && git pull 2>&1`;
$result = `cd "$dir" && git log --grep="^r$revision trunk$" 2>/dev/null | head -1`;
if ($result != "") { $result = substr ($result, strlen ("commit ")); }
$hash = $result;
} elseif ($hash != "") {
# search SVN revision number
$update = `cd "$dir" && git pull 2>&1`;
$result = `cd "$dir" && git log -n1 "$hash" 2>/dev/null`;
if ($result != "") {
$lines = explode ("\n", trim ($result));
$hash = substr ($lines[0], strlen ("commit "));
$result = rtrim (ltrim (end ($lines), " r\t"), " trunk");
}
$revision = $result;
} else {
header ("Location: /download.php");
}
if (empty ($revision) || ($revision == "")) { $revision = "SVN revision not found!"; }
if (empty ($hash) || ($hash == "")) { $hash = "GIT hash not found!"; }
if ($output == "plain") {
print $result;
} else {
include "inc/header.inc";
?>
<div class="centcolumnpad">
<h2>Translation between SVN and GIT</h2>
<h3>• SVN revision number:</h3>
<div class="codescroll"><code><?php echo $revision; ?></code></div>
<h3>• GIT hash:</h3>
<div class="codescroll"><code><?php echo $hash; ?></code></div>
<p>=> <a href="https://github.com/pencil-code/pencil-code/commit/<?php echo $hash; ?>">Commit details</a></p>
</div>
<?php
include "inc/download.inc";
include "inc/footer.inc";
}
?>