Exemplo n.º 1
0
try {
    // Annoyingly, we have to parse the raw POSTDATA.
    $payload = json_decode(file_get_contents('php://input'), 1);
    // Only execute if we have a github push.
    if (!isset($_SERVER['HTTP_X_HUB_SIGNATURE'])) {
        poc_error('No signature header');
    }
    if (!isset($secrets['gh_token'])) {
        poc_error('No GH Token found');
    }
    // TODO: pick up other branches
    // TODO: DRY this out
    exec("git fetch {$remote_url} master:_lean_upstream", $output, $status);
    if ($status !== 0) {
        poc_error("Fetch error - {$status}", $output);
    }
    exec('git merge -s recursive -Xtheirs _lean_upstream -m "From upstream: ' . $payload['head_commit']['message'] . '"', $output, $status);
    if ($status == 128) {
        poc_error("Uncommitted changes present - Merge blocked", $output);
    } elseif ($status !== 0) {
        poc_error("Merge error - {$status}", $output);
    }
    // Push merged lean changes up to Pantheon's internal repo
    exec('git push origin master', $output, $status);
    // This will trigger a sync_code and do a build.
    print_r($output);
} catch (Exception $e) {
    // Try and emit an error message to the dashboard if there was a fail.
    poc_error($e->getMessage(), $e);
}
// Comment
Exemplo n.º 2
0
 echo "Looking for files to push upstream...\n";
 #echo "git diff --name-only HEAD HEAD~1";
 #echo `cd $workspace && git diff HEAD HEAD~1`;
 #echo `git diff --name-only HEAD HEAD~1`;
 #echo `git rev-parse HEAD~1`;
 exec('git diff --name-only HEAD HEAD~1 2>&1', $output, $status);
 foreach ($output as $file) {
     if (`git cat-file _lean_upstream:{$file} -e` === NULL) {
         $lean_files[] = $file;
     } else {
         $non_lean_files[] = $file;
     }
 }
 if (count($lean_files) > 0 && count($non_lean_files) > 0) {
     // We crossed the streams.
     poc_error('Mixed commit fail!');
 }
 if (count($lean_files) > 0 && count($non_lean_files) == 0) {
     // Push the most recent hash.
     echo "Last commit was just files tracked upstream:\n\n";
     echo implode("\n", $lean_files);
     echo "\n\nPushing...\n";
     echo "\ncd {$workspace} && git push . {$SHA}:_lean_upstream 2>&1\n";
     echo `cd {$workspace} && git push . {$SHA}:_lean_upstream 2>&1`;
     echo "\ngit push {$remote_url} _lean_upstream:master 2>&1\n";
     echo `git push {$remote_url} _lean_upstream:master 2>&1`;
 } else {
     echo "No commits to push back upstream. All is well.";
 }
 // TODO, handle other branches
 // echo `git symbolic-ref -q HEAD`;