Completed
Push — master ( a9ea1a...62657b )
by Andrii
05:05
created

GitController::actionPush()   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 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * Automation tool mixed with code generator for easier continuous development
5
 *
6
 * @link      https://github.com/hiqdev/hidev
7
 * @package   hidev
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\controllers;
13
14
use yii\base\InvalidConfigException;
15
16
/**
17
 * Controller for Git.
18
 */
19
class GitController extends VcsController
20
{
21
    protected $_before = ['.gitignore'];
22
23
    /**
24
     * @var string current tag
25
     */
26
    protected $tag;
27
28
    public function actionRelease($version = null)
29
    {
30
        $version = $this->takeGoal('version')->getVersion($version);
31
        $message = "version bump to $version";
32
        $this->actionCommit($message);
33
        /// $this->actionTag($version);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
        return $this->actionPush();
35
    }
36
37
    public function actionCommit($message)
38
    {
39
        return $this->passthru('git', ['commit', '-am', $message]);
40
    }
41
42
    public function actionPush()
43
    {
44
        return $this->passthru('git', 'push');
45
    }
46
47
    public function getUserName()
48
    {
49
        return trim(`git config --get user.name`);
50
    }
51
52
    public function getUserEmail()
53
    {
54
        return trim(`git config --get user.email`);
55
    }
56
57
    public function getYear()
58
    {
59
        $date = `git log --reverse --pretty=%ai | head -n 1`;
60
        $year = $date ? date('Y', strtotime($date)) : '';
61
62
        return $year;
63
    }
64
}
65