gerritChangeId() public method

public gerritChangeId ( ) : string
return string Gerrit Change-Id
Beispiel #1
0
 /**
  * Fails if review is not approved & verified in Gerrit
  * @param Commit $commit A git commit with a Change-Id
  * @throws GitHookException If Change-Id not found or the review is not approved or verified
  */
 public function run(Commit $commit)
 {
     try {
         $changeId = $commit->gerritChangeId();
     } catch (GitException $e) {
         $this->logger->warn("{$e->getMessage()}. Skipping commit.");
         throw new GitHookException("Couldn't get Change-Id for {$commit}", $e->getCode(), $e);
     }
     /** @var \Bart\Gerrit\Change $change */
     $change = Diesel::create('\\Bart\\Gerrit\\Change', $changeId);
     if (!$change->isReviewedAndVerified()) {
         $msg = "Could not find an approved & verified change in Gerrit for change {$changeId} in commit {$commit}";
         $this->logger->info($msg);
         throw new GitHookException($msg);
     }
     $this->logger->info('Gerrit approved.');
 }
Beispiel #2
0
 /**
  * Run the hook
  * @param Commit $commit Commit with Gerrit Change-Id
  * @throws GitHookException if requirement fails
  */
 public function run(Commit $commit)
 {
     try {
         $changeId = $commit->gerritChangeId();
     } catch (GitException $e) {
         $this->logger->warn("{$e->getMessage()}. Skipping commit.");
         throw new GitHookException("Couldn't get Change-Id for {$commit}", $e->getCode(), $e);
     }
     $change = new Change($changeId);
     try {
         if (!$change->exists()) {
             // This is not a warning, because some repositories do not require code review
             $this->logger->info('Skipping change b/c it does not exist in Gerrit');
             return;
         }
         $change->abandon("Abandoning from git hook for commit {$commit}.");
     } catch (GerritException $e) {
         $this->logger->error("Problem abandoning Gerrit review {$changeId}", $e);
         throw new GitHookException("Problem abandoning Gerrit review {$changeId}", $e->getCode(), $e);
     }
 }
Beispiel #3
0
 /**
  * Run the hook
  * @param Commit $commit Commit with Gerrit Change-Id
  * @throws GitHookException if requirement fails
  */
 public function run(Commit $commit)
 {
     try {
         $changeId = $commit->gerritChangeId();
     } catch (GitException $e) {
         $this->logger->warn("{$e->getMessage()}. Skipping commit.");
         throw new GitHookException("Couldn't get Change-Id for {$commit}", $e->getCode(), $e);
     }
     $change = new Change($changeId);
     try {
         if (!$change->exists()) {
             // This is not a warning, because some repositories do not require code review
             $this->logger->debug('Skipping change b/c it does not exist in Gerrit');
             return;
         }
         $change->markMerged($commit->revision());
         $change->comment("Git hook marking {$changeId} as merged by {$commit}");
     } catch (GerritException $e) {
         $this->logger->error("Failed to mark Gerrit reivew {$changeId} as merged", $e);
         throw new GitHookException("Failed to mark Gerrit reivew {$changeId} as merged", $e->getCode(), $e);
     }
 }