diff --git a/src/work/ArcanistWorkEngine.php b/src/work/ArcanistWorkEngine.php --- a/src/work/ArcanistWorkEngine.php +++ b/src/work/ArcanistWorkEngine.php @@ -197,7 +197,8 @@ $task_symbol, ArcanistSymbolRef::HARDPOINT_OBJECT); - $task_ref = $task_symbol->getObject(); + $task_ref = $task_symbol->getObject(); + if (!$task_ref) { throw new PhutilArgumentUsageException( pht( @@ -205,11 +206,31 @@ $symbol)); } - throw new Exception(pht('TODO: Implement this workflow.')); + $task_name = $task_ref->getName(); + // TODO: check mercurial and subversion. This is just git + $pattern = '#^[./]|\.\.|@{|[/.]$|^@$|[~^:\x00-\x20\x7F?*[\\\\]#'; + $branch_name = preg_replace($pattern, '-', $task_name); + $branch_name = trim($branch_name, '-'); + $branch_name = strtolower($branch_name); + $branch_name = $task_ref->getMonogram().'-'.$branch_name; + // keep length to GitHub max + $branch_name = rtrim(substr($branch_name, 0, 244), '-'); + // below should work unless in detached HEAD state?? + $start = id($this->getRepositoryAPI())->getBranchName(); + if (!$start) { + // test detached HEAD?? + $start = id($this->getRepositoryAPI())->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); + */ } }