@@ -150,7 +150,7 @@ function getGithubApiEndpoint(string $endpoint): ?stdClass
150
150
CURLOPT_FOLLOWLOCATION => true ,
151
151
CURLOPT_HTTPGET => true ,
152
152
CURLOPT_HTTPHEADER => [
153
- 'User-Agent: spatie-configure-script/1.0 '
153
+ 'User-Agent: spatie-configure-script/1.0 ' ,
154
154
],
155
155
]);
156
156
@@ -171,26 +171,27 @@ function getGithubApiEndpoint(string $endpoint): ?stdClass
171
171
172
172
function searchCommitsForGithubUsername (): string
173
173
{
174
- $ authorName = strtolower (trim (shell_exec (" git config user.name " )));
174
+ $ authorName = strtolower (trim (shell_exec (' git config user.name ' )));
175
175
176
176
$ committersRaw = shell_exec ("git log --author='@users.noreply.github.com' --pretty='%an:%ae' --reverse " );
177
177
$ committersLines = explode ("\n" , $ committersRaw );
178
- $ committers = array_filter (array_map (function ($ line ) use ($ authorName ) {
178
+ $ committers = array_filter (array_map (function ($ line ) use ($ authorName ) {
179
179
$ line = trim ($ line );
180
180
[$ name , $ email ] = explode (': ' , $ line ) + [null , null ];
181
181
182
182
return [
183
183
'name ' => $ name ,
184
184
'email ' => $ email ,
185
- 'isMatch ' => strtolower ($ name ) === $ authorName && !str_contains ($ name , '[bot] ' )
185
+ 'isMatch ' => strtolower ($ name ) === $ authorName && ! str_contains ($ name , '[bot] ' ),
186
186
];
187
- }, $ committersLines ), fn ($ item ) => $ item ['isMatch ' ]);
187
+ }, $ committersLines ), fn ($ item ) => $ item ['isMatch ' ]);
188
188
189
189
if (empty ($ committers )) {
190
190
return '' ;
191
191
}
192
192
193
193
$ firstCommitter = reset ($ committers );
194
+
194
195
return explode ('@ ' , $ firstCommitter ['email ' ])[0 ] ?? '' ;
195
196
}
196
197
@@ -210,25 +211,25 @@ function guessGithubUsernameUsingCli()
210
211
function guessGithubUsername (): string
211
212
{
212
213
$ username = searchCommitsForGithubUsername ();
213
- if (!empty ($ username )) {
214
+ if (! empty ($ username )) {
214
215
return $ username ;
215
216
}
216
217
217
218
$ username = guessGithubUsernameUsingCli ();
218
- if (!empty ($ username )) {
219
+ if (! empty ($ username )) {
219
220
return $ username ;
220
221
}
221
222
222
223
// fall back to using the username from the git remote
223
- $ remoteUrl = shell_exec (" git config remote.origin.url " );
224
+ $ remoteUrl = shell_exec (' git config remote.origin.url ' );
224
225
$ remoteUrlParts = explode ('/ ' , str_replace (': ' , '/ ' , trim ($ remoteUrl )));
225
226
226
227
return $ remoteUrlParts [1 ] ?? '' ;
227
228
}
228
229
229
230
function guessGithubVendorInfo ($ authorName , $ username ): array
230
231
{
231
- $ remoteUrl = shell_exec (" git config remote.origin.url " );
232
+ $ remoteUrl = shell_exec (' git config remote.origin.url ' );
232
233
$ remoteUrlParts = explode ('/ ' , str_replace (': ' , '/ ' , trim ($ remoteUrl )));
233
234
234
235
$ response = getGithubApiEndpoint ("orgs/ {$ remoteUrlParts [1 ]}" );
0 commit comments