Completed
Push — master ( a13e0c...77f861 )
by Andrii
05:45
created

GitController::actionTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\controllers;
12
13
/**
14
 * Controller for Git.
15
 */
16
class GitController extends VcsController
17
{
18
    protected $_before = ['.gitignore'];
19
20
    /**
21
     * @var string current tag
22
     */
23
    protected $tag;
24
25
    public function actionRelease($version = null)
26
    {
27
        $version = $this->takeGoal('version')->getVersion($version);
28
        $message = "version bump to $version";
29
        $this->actionCommit($message);
30
        $this->actionTag($version);
31
32
        return $this->actionPush();
33
    }
34
35
    public function actionCommit($message)
36
    {
37
        return $this->passthru('git', ['commit', '-am', $message]);
38
    }
39
40
    public function actionTag($tag)
41
    {
42
        return $this->passthru('git', ['tag', $tag]);
43
    }
44
45
    public function actionPush()
46
    {
47
        return $this->passthru('git', 'push', '--tags');
0 ignored issues
show
Unused Code introduced by
The call to GitController::passthru() has too many arguments starting with '--tags'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
48
    }
49
50
    public function getUserName()
51
    {
52
        return trim(`git config --get user.name`);
53
    }
54
55
    public function getUserEmail()
56
    {
57
        return trim(`git config --get user.email`);
58
    }
59
60
    public function getYear()
61
    {
62
        $date = `git log --reverse --pretty=%ai | head -n 1`;
63
        $year = $date ? date('Y', strtotime($date)) : '';
64
65
        return $year;
66
    }
67
}
68