getOption('revision'); if (!$targetRevision) { $ref = 'HEAD'; $opt = ''; if ($tag = input()->getOption('tag')) { $ref = $tag; $opt = '--tags'; } elseif ($branch = get('branch')) { $ref = $branch; $opt = '--heads'; } $remoteLs = runLocally("git ls-remote $opt $repository $ref"); if (strstr($remoteLs, "\n")) { throw new Exception("Could not determine target revision. '$ref' matched multiple commits."); } if (!$remoteLs) { throw new Exception("Could not resolve a revision from '$ref'."); } $targetRevision = substr($remoteLs, 0, strpos($remoteLs, "\t")); } // Compare commit hashes. We use strpos to support short versions. $targetRevision = trim($targetRevision); $lastDeployedRevision = run('cat {{current_path}}/REVISION'); if ($targetRevision && strpos($lastDeployedRevision, $targetRevision) === 0) { throw new GracefulShutdownException("Already up-to-date."); } info("deployed different version"); });