Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14428524
D7633.id17239.diff
No One
Temporary
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.id17239.diff
View Options
Index: scripts/ssh/ssh-connect.php
===================================================================
--- scripts/ssh/ssh-connect.php
+++ scripts/ssh/ssh-connect.php
@@ -7,21 +7,6 @@
$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();
@@ -30,8 +15,9 @@
$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';
Index: src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
===================================================================
--- src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
+++ 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();
+ }
+ }
}
Index: src/applications/repository/storage/PhabricatorRepository.php
===================================================================
--- src/applications/repository/storage/PhabricatorRepository.php
+++ 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/plain
Expires
Thu, Dec 26, 3:09 PM (6 h, 4 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6927311
Default Alt Text
D7633.id17239.diff (3 KB)
Attached To
Mode
D7633: Actually push to mirrors
Attached
Detach File
Event Timeline
Log In to Comment