|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace markmarco16\git\controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
use yii\web\Controller; |
|
7
|
|
|
use yii\data\ArrayDataProvider; |
|
8
|
|
|
use markmarco16\git\components\Repository; |
|
9
|
|
|
use markmarco16\git\Asset; |
|
10
|
|
|
|
|
11
|
|
|
class DefaultController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
public function init() |
|
15
|
|
|
{ |
|
16
|
|
|
parent::init(); |
|
17
|
|
|
\markmarco16\git\Asset::register($this->view); |
|
|
|
|
|
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function actionIndex() |
|
21
|
|
|
{ |
|
22
|
|
|
$git = new Repository(); |
|
23
|
|
|
$provider = new ArrayDataProvider([ |
|
24
|
|
|
'allModels' => $git->getRepositoriesList(), |
|
25
|
|
|
'sort' => [ |
|
26
|
|
|
'attributes' => ['name', 'author_datetime'], |
|
27
|
|
|
], |
|
28
|
|
|
'pagination' => [ |
|
29
|
|
|
'pageSize' => 10, |
|
30
|
|
|
], |
|
31
|
|
|
]); |
|
32
|
|
|
return $this->render('index', array('git'=>$git, 'dataProvider'=>$provider)); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function actionView($id) |
|
36
|
|
|
{ |
|
37
|
|
|
$git = new Repository($id); |
|
38
|
|
|
$providerRevList = new ArrayDataProvider([ |
|
39
|
|
|
'allModels' => $git->getRevList("--all", 0, 200), |
|
40
|
|
|
'sort' => [ |
|
41
|
|
|
'attributes' => ['author_name', 'author_datetime', 'author_mail'], |
|
42
|
|
|
], |
|
43
|
|
|
'pagination' => [ |
|
44
|
|
|
'pageSize' => 25, |
|
45
|
|
|
], |
|
46
|
|
|
]); |
|
47
|
|
|
$providerTags = new ArrayDataProvider([ |
|
48
|
|
|
'allModels' => $git->getTags(), |
|
49
|
|
|
'sort' => [ |
|
50
|
|
|
'attributes' => ['h','datetime'], |
|
51
|
|
|
], |
|
52
|
|
|
'pagination' => [ |
|
53
|
|
|
'pageSize' => 25, |
|
54
|
|
|
], |
|
55
|
|
|
]); |
|
56
|
|
|
$providerBranches = new ArrayDataProvider([ |
|
57
|
|
|
'allModels' => $git->getBranches(), |
|
58
|
|
|
'sort' => [ |
|
59
|
|
|
'attributes' => ['branch', 'active'], |
|
60
|
|
|
], |
|
61
|
|
|
'pagination' => [ |
|
62
|
|
|
'pageSize' => 25, |
|
63
|
|
|
], |
|
64
|
|
|
]); |
|
65
|
|
|
return $this->render('view',array('git' => $git, 'providerRevList' => $providerRevList, 'providerTags' => $providerTags, 'providerBranches' => $providerBranches)); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function actionGraph($id) |
|
69
|
|
|
{ |
|
70
|
|
|
$git = new Repository($id); |
|
71
|
|
|
$graph = $git->showGraphLog(); |
|
72
|
|
|
return $this->render('graph',array('git'=>$git, 'graph'=>$graph)); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function actionCommitview($id, $hash, $hash_file = null) |
|
76
|
|
|
{ |
|
77
|
|
|
$git = new Repository($id); |
|
78
|
|
|
$changed = $git->getRevListHashDetail($hash); |
|
79
|
|
|
$providerFiles = new ArrayDataProvider([ |
|
80
|
|
|
'allModels' => $git->getChangedPaths($hash), |
|
81
|
|
|
'sort' => [ |
|
82
|
|
|
'attributes' => ['name', 'type', 'mode', 'size'], |
|
83
|
|
|
], |
|
84
|
|
|
'pagination' => false, |
|
85
|
|
|
]); |
|
86
|
|
|
$files_change = null; |
|
87
|
|
|
if (!($hash_file == null)) { |
|
88
|
|
|
$files_change = $git->showDiffPath($hash, $hash_file); |
|
89
|
|
|
} |
|
90
|
|
|
return $this->render('commitview',array('git' => $git, 'hash' => $hash, 'changed' => $changed, 'files_change' => $files_change, 'providerFiles' => $providerFiles)); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function actionBlob($id,$hash,$hash_file) |
|
94
|
|
|
{ |
|
95
|
|
|
$git = new Repository($id); |
|
96
|
|
|
$commit = $git->getRevListHashDetail($hash); |
|
97
|
|
|
$file = $git->showBlobFile($hash_file); |
|
98
|
|
|
return $this->render('blob', array('git' => $git, 'hash' => $hash, 'hash_file' => $hash_file, 'file' => $file, 'commit' => $commit)); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function actionTree($id, $hash, $tree) |
|
102
|
|
|
{ |
|
103
|
|
|
$git = new Repository ($id); |
|
104
|
|
|
$commit = $git->getRevListHashDetail($hash); |
|
105
|
|
|
$providerFiles = new ArrayDataProvider([ |
|
106
|
|
|
'allModels' => $git->getTree($tree,$hash), |
|
107
|
|
|
'sort' => [ |
|
108
|
|
|
'attributes' => ['name', 'type', 'mode', 'size'], |
|
109
|
|
|
], |
|
110
|
|
|
'pagination' => false, |
|
111
|
|
|
]); |
|
112
|
|
|
return $this->render('tree', array('git' => $git, 'hash' => $hash, 'commit' => $commit, 'providerFiles' => $providerFiles)); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function actionShortlog($id, $branch) |
|
116
|
|
|
{ |
|
117
|
|
|
$git = new Repository ($id); |
|
118
|
|
|
$providerRevList = new ArrayDataProvider([ |
|
119
|
|
|
'allModels' => $git->getRevList($branch, 0, 200), |
|
120
|
|
|
'sort' => [ |
|
121
|
|
|
'attributes' => ['author_name', 'author_datetime', 'author_mail'], |
|
122
|
|
|
], |
|
123
|
|
|
'pagination' => [ |
|
124
|
|
|
'pageSize' => 25, |
|
125
|
|
|
], |
|
126
|
|
|
]); |
|
127
|
|
|
return $this->render('shortlog',array('git'=>$git, 'branch'=>$branch, 'providerRevList'=>$providerRevList)); |
|
128
|
|
|
} |
|
129
|
|
|
} |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.