Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15332689
D21375.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
D21375.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -218,6 +218,7 @@
'ArcanistGitRawCommit' => 'repository/raw/ArcanistGitRawCommit.php',
'ArcanistGitRawCommitTestCase' => 'repository/raw/__tests__/ArcanistGitRawCommitTestCase.php',
'ArcanistGitRepositoryMarkerQuery' => 'repository/marker/ArcanistGitRepositoryMarkerQuery.php',
+ 'ArcanistGitRepositoryRemoteQuery' => 'repository/remote/ArcanistGitRepositoryRemoteQuery.php',
'ArcanistGitUpstreamPath' => 'repository/api/ArcanistGitUpstreamPath.php',
'ArcanistGitWorkEngine' => 'work/ArcanistGitWorkEngine.php',
'ArcanistGitWorkingCopy' => 'workingcopy/ArcanistGitWorkingCopy.php',
@@ -1246,6 +1247,7 @@
'ArcanistGitRawCommit' => 'Phobject',
'ArcanistGitRawCommitTestCase' => 'PhutilTestCase',
'ArcanistGitRepositoryMarkerQuery' => 'ArcanistRepositoryMarkerQuery',
+ 'ArcanistGitRepositoryRemoteQuery' => 'ArcanistRepositoryRemoteQuery',
'ArcanistGitUpstreamPath' => 'Phobject',
'ArcanistGitWorkEngine' => 'ArcanistWorkEngine',
'ArcanistGitWorkingCopy' => 'ArcanistWorkingCopy',
diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php
--- a/src/repository/api/ArcanistGitAPI.php
+++ b/src/repository/api/ArcanistGitAPI.php
@@ -1763,4 +1763,8 @@
return new ArcanistGitRepositoryMarkerQuery();
}
+ protected function newRemoteRefQueryTemplate() {
+ return new ArcanistGitRepositoryRemoteQuery();
+ }
+
}
diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php
--- a/src/repository/api/ArcanistMercurialAPI.php
+++ b/src/repository/api/ArcanistMercurialAPI.php
@@ -1014,7 +1014,6 @@
return new ArcanistMercurialRepositoryRemoteQuery();
}
-
public function getMercurialExtensionArguments() {
$path = phutil_get_library_root('arcanist');
$path = dirname($path);
diff --git a/src/repository/remote/ArcanistGitRepositoryRemoteQuery.php b/src/repository/remote/ArcanistGitRepositoryRemoteQuery.php
new file mode 100644
--- /dev/null
+++ b/src/repository/remote/ArcanistGitRepositoryRemoteQuery.php
@@ -0,0 +1,63 @@
+<?php
+
+final class ArcanistGitRepositoryRemoteQuery
+ extends ArcanistRepositoryRemoteQuery {
+
+ protected function newRemoteRefs() {
+ $api = $this->getRepositoryAPI();
+
+ $future = $api->newFuture('remote --verbose');
+ list($lines) = $future->resolve();
+
+ $pattern =
+ '(^'.
+ '(?P<name>[^\t]+)'.
+ '\t'.
+ '(?P<uri>[^\s]+)'.
+ ' '.
+ '\((?P<mode>fetch|push)\)'.
+ '\z'.
+ ')';
+
+ $map = array();
+
+ $lines = phutil_split_lines($lines, false);
+ foreach ($lines as $line) {
+ $matches = null;
+ if (!preg_match($pattern, $line, $matches)) {
+ throw new Exception(
+ pht(
+ 'Failed to match remote pattern against line "%s".',
+ $line));
+ }
+
+ $name = $matches['name'];
+ $uri = $matches['uri'];
+ $mode = $matches['mode'];
+
+ $map[$name][$mode] = $uri;
+ }
+
+ $refs = array();
+ foreach ($map as $name => $uris) {
+ $fetch_uri = idx($uris, 'fetch');
+ $push_uri = idx($uris, 'push');
+
+ $ref = id(new ArcanistRemoteRef())
+ ->setRemoteName($name);
+
+ if ($fetch_uri !== null) {
+ $ref->setFetchURI($fetch_uri);
+ }
+
+ if ($push_uri !== null) {
+ $ref->setPushURI($push_uri);
+ }
+
+ $refs[] = $ref;
+ }
+
+ return $refs;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 8, 7:12 PM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7226170
Default Alt Text
D21375.diff (3 KB)
Attached To
Mode
D21375: Support generating remote refs in Git
Attached
Detach File
Event Timeline
Log In to Comment