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); |
|
|
|
|
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
|
|
|
|
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.