Skip to content

Instantly share code, notes, and snippets.

@ebta
Created July 27, 2015 04:44
Show Gist options
  • Save ebta/a269b26f702b80b08d80 to your computer and use it in GitHub Desktop.
Save ebta/a269b26f702b80b08d80 to your computer and use it in GitHub Desktop.
Fossil checkout (server side) through PHP
<?php
/* fossil-checkout.php
* Untuk melakukan checkout fossil di server tanpa harus login SSH
*
* Agar bisa berjalan, Fossil butuh HOME variabel : putenv()
* Add server environment. The environment variable will only exist
* for the duration of the current request. At the end of the request
* the environment is restored to its original state
* */
$repo_name = 'simrenda.fossil';
if( putenv("HOME=". dirname(__FILE__)) ) {
$opened = shell_exec("fossil open $repo_name --keep 2>&1");
echo "<strong>Informasi Open Repository</strong>";
echo "<pre>$opened</pre><hr />";
$update = shell_exec('fossil checkout trunk --force 2>&1');
echo "<strong>Informasi files/folder yg di update:</strong>";
echo "<pre>$update</pre><hr/ >";
$output = shell_exec('fossil status 2>&1');
echo "<strong>Status Repository:</strong>";
echo "<pre>$output</pre>";
} else {
echo "Gagal mengeset HOME di php, Fossil butuh ini";
}
echo '<hr />';
$version = system('fossil version');
echo '<hr />';
// Clear environment variable
putenv('HOME');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment