mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Allow running arc patch
without authentication.
Summary: Allow `arc patch` without authentication if Phabricator instance has 'differential.anonymous-access' set to true. Test Plan: Set 'differential.anonymous-access' in Phabricator to true and run `arc patch` without installing a certificate. `arc patch` should work as expected. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: 1069
This commit is contained in:
parent
f1874ddf33
commit
9070a123d3
1 changed files with 37 additions and 30 deletions
|
@ -135,10 +135,6 @@ EOTEXT
|
||||||
($this->getSource() == self::SOURCE_DIFF);
|
($this->getSource() == self::SOURCE_DIFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requiresAuthentication() {
|
|
||||||
return $this->requiresConduit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function requiresRepositoryAPI() {
|
public function requiresRepositoryAPI() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -159,33 +155,44 @@ EOTEXT
|
||||||
|
|
||||||
$source = $this->getSource();
|
$source = $this->getSource();
|
||||||
$param = $this->getSourceParam();
|
$param = $this->getSourceParam();
|
||||||
switch ($source) {
|
try {
|
||||||
case self::SOURCE_PATCH:
|
switch ($source) {
|
||||||
if ($param == '-') {
|
case self::SOURCE_PATCH:
|
||||||
$patch = @file_get_contents('php://stdin');
|
if ($param == '-') {
|
||||||
if (!strlen($patch)) {
|
$patch = @file_get_contents('php://stdin');
|
||||||
throw new ArcanistUsageException(
|
if (!strlen($patch)) {
|
||||||
"Failed to read patch from stdin!");
|
throw new ArcanistUsageException(
|
||||||
|
"Failed to read patch from stdin!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$patch = Filesystem::readFile($param);
|
||||||
}
|
}
|
||||||
} else {
|
$bundle = ArcanistBundle::newFromDiff($patch);
|
||||||
$patch = Filesystem::readFile($param);
|
break;
|
||||||
}
|
case self::SOURCE_BUNDLE:
|
||||||
$bundle = ArcanistBundle::newFromDiff($patch);
|
$path = $this->getArgument('arcbundle');
|
||||||
break;
|
$bundle = ArcanistBundle::newFromArcBundle($path);
|
||||||
case self::SOURCE_BUNDLE:
|
break;
|
||||||
$path = $this->getArgument('arcbundle');
|
case self::SOURCE_REVISION:
|
||||||
$bundle = ArcanistBundle::newFromArcBundle($path);
|
$bundle = $this->loadRevisionBundleFromConduit(
|
||||||
break;
|
$this->getConduit(),
|
||||||
case self::SOURCE_REVISION:
|
$param);
|
||||||
$bundle = $this->loadRevisionBundleFromConduit(
|
break;
|
||||||
$this->getConduit(),
|
case self::SOURCE_DIFF:
|
||||||
$param);
|
$bundle = $this->loadDiffBundleFromConduit(
|
||||||
break;
|
$this->getConduit(),
|
||||||
case self::SOURCE_DIFF:
|
$param);
|
||||||
$bundle = $this->loadDiffBundleFromConduit(
|
break;
|
||||||
$this->getConduit(),
|
}
|
||||||
$param);
|
} catch (Exception $ex) {
|
||||||
break;
|
if ($ex->getErrorCode() == 'ERR-INVALID-SESSION') {
|
||||||
|
// Phabricator is not configured to allow anonymos access to
|
||||||
|
// Differential.
|
||||||
|
$this->authenticateConduit();
|
||||||
|
return $this->run();
|
||||||
|
} else {
|
||||||
|
throw $ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$repository_api = $this->getRepositoryAPI();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
|
|
Loading…
Reference in a new issue