Completed
Push — master ( a8bbce...8295bf )
by Tomáš
05:19 queued 02:59
created

GihubPublishingProcess::setupTravisIdentityToGit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 5
cp 0
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\PHP7_Sculpin\Github;
11
12
use Symfony\Component\Process\Process;
13
14
final class GihubPublishingProcess
15
{
16
    public function setupTravisIdentityToGit()
17
    {
18
        if (getenv('TRAVIS')) {
19
            (new Process('git config user.email "[email protected]"'))->run();
20
            (new Process('git config user.name "Travis"'))->run();
21
        }
22
    }
23
24
    public function addAndPushContentToGithubRepository(string $outputDirectory, string $githubRepository)
25
    {
26
        (new Process(sprintf('cd %s', $outputDirectory)))->run();
27
        (new Process('git init && git add . && git commit -m "Regenerate output"'))->run();
28
29
        (new Process(sprintf(
30
            'git push --force --quiet "${%s}" master:gh-pages > /dev/null 2>&1',
31
            $githubRepository
32
        )))->run();
33
    }
34
}
35