Ajout du force push

This commit is contained in:
Michel Roux 2014-04-14 15:02:53 +02:00
parent a621cd1521
commit beb829da46
5 changed files with 95 additions and 75 deletions

View File

@ -41,12 +41,19 @@ if (!empty($_POST['action'])) {
if ($_POST['action'] == 'status') {
echo ansi2html($session->exec('bash -c \'cd ' . $config['path'] . ' && ' . $gitstatus . "'"));
exit;
} else if ($_POST['action'] == 'push') {
$message = empty($_POST['message']) ? 'FTP' : str_replace(array('"', "'"), ' ', stripslashes($_POST['message']));
echo ansi2html($session->exec('bash -c \'cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push && git push && ' . $gitstatus . "'"));
} else if (strpos($_POST['action'], 'push') !== false) {
if (strpos($_POST['action'], 'force') !== false) {
echo ansi2html($session->exec('bash -c \'cd ' . $config['path'] . ' && git push && ' . $gitstatus . "'"));
if (!empty($config['after_push'])) {
echo ansi2html($session->exec('bash -c \'cd ' . $config['path'] . ' && ' . $config['after_push'] . "'"));
}
} else {
$message = empty($_POST['message']) ? 'FTP' : str_replace(array('"', "'"), ' ', stripslashes($_POST['message']));
echo ansi2html($session->exec('bash -c \'cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push && ' . $gitstatus . "'"));
if (!empty($config['after_push'])) {
echo ansi2html($session->exec('bash -c \'cd ' . $config['path'] . ' && ' . $config['after_push'] . "'"));
}
}
exit;
} else if ($_POST['action'] == 'pull') {
echo ansi2html($session->exec('bash -c \'cd ' . $config['path'] . ' && git pull && ' . $gitstatus . "'"));

View File

@ -23,11 +23,9 @@ pre {
.toolbar-bottom {
margin-top: -1px;
}
.toolbar-bottom {
display: block;
padding-right: 79px;
margin-right: 25px;
}
.toolbar-bottom .input-block-level {
@ -40,6 +38,16 @@ pre {
border-top-right-radius: 0 !important;
}
.toolbar-bottom .btn:last-child i:last-child {
position: relative;
right: 9px;
margin-right: -9px;
}
.toolbar-bottom .btn:last-child {
width: 20px;
}
.span9 {
float: right;
}

View File

@ -32,6 +32,7 @@ global $servers;
<?php foreach ($ssh as $id => $param): ?>
<section id="<?php echo $id; ?>">
<h3><?php echo $param['title']; ?></h3>
<div class="pull-right"><span class="label"></span></div>
<div class="btn-group toolbar-top">
<button class="btn" onclick="callRequest('status', '<?php echo $id; ?>');">
@ -47,6 +48,9 @@ global $servers;
<button class="btn" onclick="callRequest('push', '<?php echo $id; ?>', document.querySelector('#<?php echo $id; ?> input[name=message]').value);">
<i class="icon-arrow-up"></i> Push
</button>
<button class="btn" title="Force Push" onclick="callRequest('push force', '<?php echo $id; ?>', document.querySelector('#<?php echo $id; ?> input[name=message]').value);">
<i class="icon-arrow-up"></i><i class="icon-arrow-up"></i>
</button>
</div>
</section>
<?php endforeach; ?>

View File

@ -9,7 +9,8 @@ if (defined('ONGITLAB') && ONGITLAB) {
}
}
function ansi2html($string) {
function ansi2html($string)
{
$dictionary = array(
'[30m' => '<span style="color:black">',
'[31m' => '<span style="color:red">',