diff --git a/lean-repo-utils.php b/lean-repo-utils.php index 2a56df5..7163b43 100644 --- a/lean-repo-utils.php +++ b/lean-repo-utils.php @@ -124,11 +124,11 @@ function push_back($fullRepository, $workDir, $upstreamRepoWithCredentials, $bui $commitToSubmit = exec("git -C $fullRepository rev-parse HEAD"); // Seatbelts: is build metadatafile modified in the HEAD commit? - $commitWithBuildMetadataFile = exec("git -C $fullRepository log -n 1 --pretty=format:%H -- $buildMetadataFile"); - if ($commitWithBuildMetadataFile == $commitToSubmit) { - print "Ignoring commit because it contains build assets.\n"; - return; - } + // $commitWithBuildMetadataFile = exec("git -C $fullRepository log -n 1 --pretty=format:%H -- $buildMetadataFile"); + // if ($commitWithBuildMetadataFile == $commitToSubmit) { + // print "Ignoring commit because it contains build assets.\n"; + // return; + // } // A working branch to make changes on $targetBranch = $branch; @@ -147,6 +147,13 @@ function push_back($fullRepository, $workDir, $upstreamRepoWithCredentials, $bui // we can make a branch off of the commit this multidev was built from. print "git rev-parse HEAD\n"; $remoteHead = exec("git -C $canonicalRepository rev-parse HEAD"); + + // If there are no changes between pantheon and remote repository, process will stop. + if ($fromSha == $remoteHead) { + print "There are no changes between repositories.\n"; + return; + } + if ($remoteHead != $fromSha) { // TODO: If we had git 2.11.0, we could use --shallow-since with the date // from $buildMetadata['commit-date'] to get exactly the commits we need. diff --git a/push-back.php b/push-back.php index 61b228a..acd0b2c 100644 --- a/push-back.php +++ b/push-back.php @@ -34,6 +34,31 @@ passthru("rm -rf $workDir"); mkdir($workDir); +// Updating metadata with pantheon repository data. +$pantheon_remoteHead = exec("git -C $fullRepository rev-parse HEAD"); +$pantheon_commit = exec("git -C $fullRepository log -1 --pretty=\"%s\""); +$pantheon_commit_date = exec("git -C $fullRepository log -1 --pretty='%ci'"); +$pantheon_build_date = date("Y-m-d H:i:s O"); + +$currentDateTime = new DateTime(); +$interval = new DateInterval('PT10M'); +$currentDateTime->sub($interval); +$pantheon_build_date = $currentDateTime->format("Y-m-d H:i:s O"); + +$fake_metadata = array( + "url" => "git@github.com:swappsco/ncarb.git", + "ref" => "master", + "sha" => $pantheon_remoteHead , + "comment" => $pantheon_commit, + "commit-date" => $pantheon_commit_date, + "build-date" => $pantheon_build_date, +); + +$jsonData = json_encode($fake_metadata, JSON_PRETTY_PRINT); +$fake_build_metadata_path = $fullRepository."/build-metadata.json"; +file_put_contents($fake_build_metadata_path, $jsonData); + +// Getting Metadata & Providers $buildProviders = load_build_providers($fullRepository); $buildMetadata = load_build_metadata($fullRepository); // The remote repo to push to