Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
e66f855e
Unverified
Commit
e66f855e
authored
Jul 02, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Download module command: Adding optional option to download a specific branch
parent
5c3f3750
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
DownloadModuleCommand.php
Modules/Core/Console/DownloadModuleCommand.php
+4
-0
Downloader.php
Modules/Core/Downloader/Downloader.php
+15
-1
No files found.
Modules/Core/Console/DownloadModuleCommand.php
View file @
e66f855e
...
@@ -33,6 +33,9 @@ class DownloadModuleCommand extends Command
...
@@ -33,6 +33,9 @@ class DownloadModuleCommand extends Command
{
{
$downloader
=
new
Downloader
(
$this
->
getOutput
());
$downloader
=
new
Downloader
(
$this
->
getOutput
());
try
{
try
{
if
(
$this
->
hasOption
(
'branch'
))
{
$downloader
->
forBranch
(
$this
->
option
(
'branch'
));
}
$downloader
->
download
(
$this
->
argument
(
'name'
));
$downloader
->
download
(
$this
->
argument
(
'name'
));
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$this
->
output
->
writeln
(
"<error>
{
$e
->
getMessage
()
}
</error>"
);
$this
->
output
->
writeln
(
"<error>
{
$e
->
getMessage
()
}
</error>"
);
...
@@ -88,6 +91,7 @@ class DownloadModuleCommand extends Command
...
@@ -88,6 +91,7 @@ class DownloadModuleCommand extends Command
[
'seeds'
,
's'
,
InputOption
::
VALUE_NONE
,
'Run the module seeds'
,
null
],
[
'seeds'
,
's'
,
InputOption
::
VALUE_NONE
,
'Run the module seeds'
,
null
],
[
'assets'
,
'a'
,
InputOption
::
VALUE_NONE
,
'Publish the module assets'
,
null
],
[
'assets'
,
'a'
,
InputOption
::
VALUE_NONE
,
'Publish the module assets'
,
null
],
[
'demo'
,
'd'
,
InputOption
::
VALUE_NONE
,
'Run all optional flags'
,
null
],
[
'demo'
,
'd'
,
InputOption
::
VALUE_NONE
,
'Run all optional flags'
,
null
],
[
'branch'
,
null
,
InputOption
::
VALUE_OPTIONAL
,
'Download a specific branch name'
,
null
],
];
];
}
}
...
...
Modules/Core/Downloader/Downloader.php
View file @
e66f855e
...
@@ -27,6 +27,10 @@ class Downloader
...
@@ -27,6 +27,10 @@ class Downloader
* @var string
* @var string
*/
*/
private
$tagName
;
private
$tagName
;
/**
* @var string
*/
private
$branchName
;
public
function
__construct
(
OutputInterface
$output
)
public
function
__construct
(
OutputInterface
$output
)
{
{
...
@@ -43,7 +47,7 @@ class Downloader
...
@@ -43,7 +47,7 @@ class Downloader
$this
->
package
=
$package
;
$this
->
package
=
$package
;
$latestVersionUrl
=
$this
->
getLatestVersionUrl
();
$latestVersionUrl
=
$this
->
getLatestVersionUrl
();
$this
->
output
->
writeln
(
"<info>Downloading Module [
{
$this
->
package
}
{
$this
->
tagName
}
]</info>"
);
$this
->
output
->
writeln
(
"<info>Downloading Module [
{
$this
->
package
}
{
$this
->
tagName
}
{
$this
->
branchName
}
]</info>"
);
$directory
=
config
(
'modules.paths.modules'
)
.
'/'
.
$this
->
extractPackageNameFrom
(
$package
);
$directory
=
config
(
'modules.paths.modules'
)
.
'/'
.
$this
->
extractPackageNameFrom
(
$package
);
...
@@ -129,6 +133,9 @@ class Downloader
...
@@ -129,6 +133,9 @@ class Downloader
private
function
getLatestVersionUrl
()
private
function
getLatestVersionUrl
()
{
{
if
(
$this
->
branchName
!==
null
)
{
return
"https://github.com/
{
$this
->
package
}
/archive/
{
$this
->
branchName
}
.zip"
;
}
$client
=
new
Client
([
$client
=
new
Client
([
'base_uri'
=>
'https://api.github.com'
,
'base_uri'
=>
'https://api.github.com'
,
'timeout'
=>
2.0
,
'timeout'
=>
2.0
,
...
@@ -153,4 +160,11 @@ class Downloader
...
@@ -153,4 +160,11 @@ class Downloader
}
}
return
studly_case
(
substr
(
strrchr
(
$package
,
'/'
),
1
));
return
studly_case
(
substr
(
strrchr
(
$package
,
'/'
),
1
));
}
}
public
function
forBranch
(
$branchName
)
{
$this
->
branchName
=
$branchName
;
return
$this
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment