Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F84632
D7633.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7633.diff
View Options
diff --git a/scripts/ssh/ssh-connect.php b/scripts/ssh/ssh-connect.php
--- a/scripts/ssh/ssh-connect.php
+++ b/scripts/ssh/ssh-connect.php
@@ -7,31 +7,17 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
-$target_name = getenv('PHABRICATOR_SSH_TARGET');
-if (!$target_name) {
- throw new Exception(pht("No 'PHABRICATOR_SSH_TARGET' in environment!"));
-}
-
-$viewer = PhabricatorUser::getOmnipotentUser();
-
-$repository = id(new PhabricatorRepositoryQuery())
- ->setViewer($viewer)
- ->withCallsigns(array($target_name))
- ->executeOne();
-if (!$repository) {
- throw new Exception(pht('No repository with callsign "%s"!', $target_name));
-}
-
$pattern = array();
$arguments = array();
$pattern[] = 'ssh';
$pattern[] = '-o';
$pattern[] = 'StrictHostKeyChecking=no';
-$credential_phid = $repository->getCredentialPHID();
+$credential_phid = getenv('PHABRICATOR_CREDENTIAL');
if ($credential_phid) {
+ $viewer = PhabricatorUser::getOmnipotentUser();
$key = PassphraseSSHKey::loadFromPHID($credential_phid, $viewer);
$pattern[] = '-l %P';
diff --git a/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php b/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
--- a/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
+++ b/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
@@ -252,6 +252,15 @@
$this->checkIfRepositoryIsFullyImported($repository);
+ try {
+ $this->pushToMirrors($repository);
+ } catch (Exception $ex) {
+ // TODO: We should report these into the UI properly, but for
+ // now just complain. These errors are much less severe than
+ // pull errors.
+ phlog($ex);
+ }
+
if ($refs !== null) {
return (bool)count($refs);
} else {
@@ -802,4 +811,43 @@
}
+ private function pushToMirrors(PhabricatorRepository $repository) {
+ if (!$repository->canMirror()) {
+ return;
+ }
+
+ $mirrors = id(new PhabricatorRepositoryMirrorQuery())
+ ->setViewer($this->getViewer())
+ ->withRepositoryPHIDs(array($repository->getPHID()))
+ ->execute();
+
+ // TODO: This is a little bit janky, but we don't have first-class
+ // infrastructure for running remote commands against an arbitrary remote
+ // right now. Just make an emphemeral copy of the repository and muck with
+ // it a little bit. In the medium term, we should pull this command stuff
+ // out and use it here and for "Land to ...".
+
+ $proxy = clone $repository;
+ $proxy->makeEphemeral();
+
+ $proxy->setDetail('hosting-enabled', false);
+ foreach ($mirrors as $mirror) {
+ $proxy->setDetail('remote-uri', $mirror->getRemoteURI());
+ $proxy->setCredentialPHID($mirror->getCredentialPHID());
+
+ $this->log(pht('Pushing to remote "%s"...', $mirror->getRemoteURI()));
+
+ if (!$proxy->isGit()) {
+ throw new Exception('Unsupported VCS!');
+ }
+
+ $future = $proxy->getRemoteCommandFuture(
+ 'push --verbose --mirror -- %s',
+ $proxy->getRemoteURI());
+
+ $future
+ ->setCWD($proxy->getLocalPath())
+ ->resolvex();
+ }
+ }
}
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -337,7 +337,7 @@
if ($this->shouldUseSSH()) {
// NOTE: This is read by `bin/ssh-connect`, and tells it which credentials
// to use.
- $env['PHABRICATOR_SSH_TARGET'] = $this->getCallsign();
+ $env['PHABRICATOR_CREDENTIAL'] = $this->getCredentialPHID();
switch ($this->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
// Force SVN to use `bin/ssh-connect`.
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/oe/4n/k2fmm2xcw3tvphsv
Default Alt Text
D7633.diff (3 KB)
Attached To
Mode
D7633: Actually push to mirrors
Attached
Detach File
Event Timeline
Log In to Comment