1
1
<?php
2
- /*
3
- * This file is part of the Artemeon Core - Web Application Framework.
4
- *
5
- * (c) Artemeon <www.artemeon.de>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
2
11
3
namespace Artemeon \M2G \Command ;
12
4
13
5
use Artemeon \M2G \Dto \GithubIssue ;
14
- use Artemeon \M2G \Dto \MantisIssue ;
15
6
use Artemeon \M2G \Service \GithubConnector ;
16
7
use Artemeon \M2G \Service \MantisConnector ;
17
- use GuzzleHttp \Exception \GuzzleException ;
18
8
use Symfony \Component \Console \Helper \ProgressBar ;
19
9
use Symfony \Component \Console \Helper \Table ;
20
10
use Symfony \Component \Console \Input \InputArgument ;
21
- use Symfony \Component \Console \Input \InputOption ;
22
11
23
12
use function Termwind \render ;
24
13
@@ -34,7 +23,6 @@ public function __construct(MantisConnector $mantisConnector, GithubConnector $g
34
23
$ this ->githubConnector = $ githubConnector ;
35
24
}
36
25
37
-
38
26
protected function configure ()
39
27
{
40
28
$ this ->setName ('sync ' )
@@ -99,15 +87,14 @@ protected function handle(): int
99
87
100
88
$ newGithubIssue = GithubIssue::fromMantisIssue ($ mantisIssue );
101
89
102
- $ filteredLabels = array_filter ($ labels , function ($ label ) use ($ mantisIssue ) {
90
+ $ filteredLabels = array_values ( array_filter ($ labels , function ($ label ) use ($ mantisIssue ) {
103
91
return strtolower ($ label ) === strtolower ($ mantisIssue ->getProject ());
104
- });
92
+ })) ;
105
93
106
94
$ newGithubIssue ->setLabels ($ filteredLabels );
95
+ $ newGithubIssue = $ this ->githubConnector ->createIssue ($ newGithubIssue );
107
96
108
- try {
109
- $ newGithubIssue = $ this ->githubConnector ->createIssue ($ newGithubIssue );
110
- } catch (GuzzleException | \Exception $ e ) {
97
+ if ($ newGithubIssue === null ) {
111
98
$ issues [] = [
112
99
'id ' => $ id ,
113
100
'icon ' => '<error>✕</error> ' ,
@@ -118,7 +105,17 @@ protected function handle(): int
118
105
}
119
106
120
107
$ mantisIssue ->setUpstreamTicket ($ newGithubIssue ->getIssueUrl ());
121
- $ this ->mantisConnector ->patchUpstreamField ($ mantisIssue );
108
+ $ patched = $ this ->mantisConnector ->patchUpstreamField ($ mantisIssue );
109
+
110
+ if ($ patched === false ) {
111
+ $ issues [] = [
112
+ 'id ' => $ id ,
113
+ 'icon ' => '<error>✕</error> ' ,
114
+ 'message ' => '<error>Upstream ticket URL could not be updated.</error> ' ,
115
+ 'issue ' => '' ,
116
+ ];
117
+ continue ;
118
+ }
122
119
123
120
$ issues [] = [
124
121
'id ' => $ id ,
0 commit comments