Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F176210
add-a-repo.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
avivey
Jul 11 2014, 12:33 AM
2014-07-11 00:33:07 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
add-a-repo.php
View Options
<?php
// use: arc import-github-repo --callsign <newcallsign> --name <human-redable-name> <git repo uri>
class
importGithubRepo
extends
ArcanistBaseWorkflow
{
public
function
getWorkflowName
()
{
return
'import-github-repo'
;
}
public
function
run
()
{
$uri
=
$this
->
getArgument
(
'uri'
);
$uri
=
idx
(
$uri
,
0
);
$callsign
=
$this
->
getArgument
(
'callsign'
);
$name
=
$this
->
getArgument
(
'name'
);
if
(!
$uri
||
!
$callsign
||
!
$name
)
throw
new
ArcanistUsageException
(
"uri, callsign, name are all required"
);
$uri
=
$this
->
fixUri
(
$uri
);
$arguments
=
array
(
'name'
=>
$name
,
'callsign'
=>
$callsign
,
'uri'
=>
$uri
,
'closeCommitsFilter'
=>
array
(
'master'
),
// TODO serverside default
'vcs'
=>
'git'
,
);
var_dump
(
$arguments
);
$response
=
$this
->
getConduit
()->
callMethodSynchronous
(
'repository.create'
,
$arguments
);
$console
=
PhutilConsole
::
getConsole
();
$console
->
writeOut
(
"%s
\n
"
,
json_encode
(
$response
,
JSON_PRETTY_PRINT
));
}
function
fixUri
(
$input
)
{
$uri
=
preg_replace
(
'/
\.
git$/'
,
''
,
$input
);
$uri
=
preg_replace
(
',^https?://,'
,
''
,
$uri
);
$uri
=
preg_replace
(
',^github.com/,'
,
''
,
$uri
);
if
(
strpos
(
$uri
,
':'
)
===
FALSE
)
$uri
=
'github:'
.
$uri
;
$uri
=
new
PhutilGitURI
(
$uri
);
if
(!
$uri
->
getDomain
())
{
throw
new
Exception
(
"can't parse uri: {$input}"
);
}
$uri
=
$uri
->
getPath
();
return
"git://github/{$uri}"
;
}
public
function
getArguments
()
{
return
array
(
'name'
=>
array
(
'param'
=>
'repo name'
,
),
'callsign'
=>
array
(
'param'
=>
'callsign'
,
),
'*'
=>
'uri'
,
);
}
public
function
requiresConduit
()
{
return
true
;
}
public
function
requiresAuthentication
()
{
return
true
;
}
public
function
getCommandHelp
()
{
return
phutil_console_format
(
<<<EOTEXT
EOTEXT
);
}
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**import-github-repo** [options] __uri__
EOTEXT
);
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/le/7q/i7iyohhzkub2olr2
Default Alt Text
add-a-repo.php (2 KB)
Attached To
Mode
P1199 add-a-repo.php
Attached
Detach File
Event Timeline
Log In to Comment