Page MenuHomePhorge

D25872.1740770341.diff
No OneTemporary

D25872.1740770341.diff

diff --git a/src/work/ArcanistWorkEngine.php b/src/work/ArcanistWorkEngine.php
--- a/src/work/ArcanistWorkEngine.php
+++ b/src/work/ArcanistWorkEngine.php
@@ -198,6 +198,7 @@
ArcanistSymbolRef::HARDPOINT_OBJECT);
$task_ref = $task_symbol->getObject();
+
if (!$task_ref) {
throw new PhutilArgumentUsageException(
pht(
@@ -205,11 +206,42 @@
$symbol));
}
- throw new Exception(pht('TODO: Implement this workflow.'));
+ $task_name = $task_ref->getName();
+ // TODO: check mercurial and subversion. This is just git
+ // see https://git-scm.com/docs/git-check-ref-format
+ $pattern = '#(^[./]+|//|/\.+|\.{2,}|@{|[/.]+$|^@$|[~^:\x00-\x20\x7F?*\[\\\\])#u';
+ $branch_name = preg_replace($pattern, '-', $task_name);
+ $branch_name = trim($branch_name, '-');
+ $branch_name = mb_convert_case($branch_name, MB_CASE_LOWER, 'UTF-8');
+ $branch_name = $task_ref->getMonogram().'-'.$branch_name;
+ // to reduce multiple '-' to single '-'
+ $branch_name = preg_replace('#-+#', '-', $branch_name);
+ // keep length to GitHub max
+ $branch_name = rtrim(mb_substr($branch_name, 0, 244), '-');
+
+ $api = $this->getRepositoryAPI();
+ list($existing_branch) = $api->execxLocal('rev-parse --verify %s', $branch_name);
+ $existing_branch = trim($existing_branch);
+
+ if ($existing_branch === $branch_name) {
+ $api->execLocal('checkout %s', $branch_name);
+ } else {
+ // below should work unless in detached HEAD state??
+ $start = id($api)->getBranchName();
+ if (!$start) {
+ // test detached HEAD??
+ $start = id($api)->getWorkingCopyRevision();
+ $this->newMarker($branch_name, $start);
+ }
+ }
- $this->loadHardpoints(
+ return id(new ArcanistMarkerRef())
+ ->setName($branch_name)
+ ->setMarkerType(ArcanistMarkerRef::TYPE_BRANCH);
+ /* $this->loadHardpoints(
$task_ref,
ArcanistTaskRef::HARDPOINT_REVISIONREFS);
+ */
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 28, 19:19 (4 w, 17 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1182568
Default Alt Text
D25872.1740770341.diff (1 KB)

Event Timeline