GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 6a3289...514d99 )
by Anton
02:27
created

recipe/deploy/check_remote.php (1 issue)

1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer;
9
10
use Deployer\Exception\Exception;
11
use Deployer\Exception\GracefulShutdownException;
12
13
// Cancel deployment if there would be no change to the codebase.
14
// This avoids unnecessary releases if the latest commit has already been deployed.
15 8
desc('Check remote head');
16
task('deploy:check_remote', function () {
17
    $repository = get('repository');
18
    if (empty($repository)) {
19
        throw new Exception("You need to specify a repository.");
20
    }
21
22
    // Skip if there is no current deployment to compare
23
    if (! test('[ -d {{deploy_path}}/current/.git ]')) {
24
        return;
25
    }
26
27
    // Determine the hash of the remote revision about to be deployed
28
    $targetRevision = input()->getOption('revision');
29
30
    if (!$targetRevision) {
31
        $ref = 'HEAD';
32
        $opt = '';
33
34
        if ($tag = input()->getOption('tag')) {
35
            $ref = $tag;
36
            $opt = '--tags';
37
        } elseif ($branch = get('branch')) {
38
            $ref = $branch;
39
            $opt = '--heads';
40
        }
41
42
        $remoteLs = null;
43
        on(localhost(), function () use (& $remoteLs, $opt, $repository, $ref) {
0 ignored issues
show
It seems like localhost() can also be of type Deployer\Support\ObjectProxy; however, parameter $hosts of Deployer\on() does only seem to accept Deployer\Host\Host[]&Deployer\Host\Host, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
        on(/** @scrutinizer ignore-type */ localhost(), function () use (& $remoteLs, $opt, $repository, $ref) {
Loading history...
44
            $getRemoteRevisionCmd = sprintf("%s ls-remote $opt $repository $ref", get('bin/git'));
45
            $remoteLs = run($getRemoteRevisionCmd);
46
        });
47
48
        if (strstr($remoteLs, "\n")) {
49
            throw new Exception("Could not determine target revision. '$ref' matched multiple commits.");
50
        }
51
        if (!$remoteLs) {
52
            throw new Exception("Could not resolve a revision from '$ref'.");
53
        }
54
55
        $targetRevision = substr($remoteLs, 0, strpos($remoteLs, "\t"));
56
    }
57
58
    // Compare commit hashes. We use strpos to support short versions.
59 8
    $targetRevision = trim($targetRevision);
60
    $lastDeployedRevision = trim(run(sprintf('cd {{deploy_path}}/current && %s rev-parse HEAD', get('bin/git'))));
61
    if ($targetRevision && strpos($lastDeployedRevision, $targetRevision) === 0) {
62
        throw new GracefulShutdownException("Already up-to-date.");
63
    }
64
});
65