Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
beardedwarrior
ffs
Commits
18d446f9
Commit
18d446f9
authored
Nov 19, 2018
by
beardedwarrior
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add command to fetch proposal merge requests
parent
f19effe2
Pipeline
#37
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
app/Console/Commands/FetchMergeRequests.php
app/Console/Commands/FetchMergeRequests.php
+88
-0
No files found.
app/Console/Commands/FetchMergeRequests.php
0 → 100644
View file @
18d446f9
<?php
namespace
App\Console\Commands
;
use
App\Project
;
use
GitLab\Connection
;
use
GuzzleHttp\Client
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Storage
;
class
fetchMergeRequests
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'gitlab:fetch-proposals'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'fetch all the proposal merge requests from gitlab'
;
/**
* Create a new command instance.
*
* @return void
*/
public
function
__construct
()
{
parent
::
__construct
();
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$connection
=
new
Connection
(
new
Client
());
$projects
=
$connection
->
mergeRequests
(
'all'
);
foreach
(
$projects
as
$project
)
{
// create requests that are still pending
$project
=
Project
::
firstOrNew
([
'merge_request_id'
=>
$project
->
id
],[
'title'
=>
$project
->
title
,
'state'
=>
$project
->
state
]);
// check if there is a payment_id and an address
// check if the amount field has been supplied
$project
->
save
();
}
// id, title, state, username,
// save merge requests
// compare to current merge requests
// if merge request is missing is it closed or merged
return
;
}
/**
* Gets the ffs amount requested from a file
*
* @param string $filename
* @return int
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public
function
getAmountFromText
(
$filename
=
'test-ffs.md'
)
{
$input
=
Storage
::
get
(
$filename
);
$lines
=
preg_split
(
'/\r\n|\r|\n/'
,
$input
);
foreach
(
$lines
as
$line
)
{
$line
=
str_replace
(
' '
,
''
,
$line
);
$details
=
explode
(
':'
,
$line
);
if
(
$details
[
0
]
===
'amount'
)
{
return
$details
[
1
];
}
}
return
0
;
}
}
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