... | ... |
@@ -1,6 +1,12 @@ |
1 | 1 |
{ |
2 |
- "hash": "1790d6792c8544b8d1c9efbf8f5fe2de", |
|
2 |
+ "hash": "9820789efd58e6b6bb6b746efb8500fe", |
|
3 | 3 |
"packages": [ |
4 |
+ { |
|
5 |
+ "package": "klaussilveira/gitter", |
|
6 |
+ "version": "dev-master", |
|
7 |
+ "source-reference": "209908f247194b1adc836f2e50f957cb1f11f41c", |
|
8 |
+ "commit-date": "1347372763" |
|
9 |
+ }, |
|
4 | 10 |
{ |
5 | 11 |
"package": "pimple/pimple", |
6 | 12 |
"version": "dev-master", |
... | ... |
@@ -10,8 +16,8 @@ |
10 | 16 |
{ |
11 | 17 |
"package": "pimple/pimple", |
12 | 18 |
"version": "dev-master", |
13 |
- "source-reference": "db836b8cfadc0f39dacafa2bf311a1ab603600bb", |
|
14 |
- "commit-date": "1343051648" |
|
19 |
+ "source-reference": "b9f27b8dc18c08f00627dec02359b46a24791dc3", |
|
20 |
+ "commit-date": "1347278988" |
|
15 | 21 |
}, |
16 | 22 |
{ |
17 | 23 |
"package": "silex/silex", |
... | ... |
@@ -22,14 +28,14 @@ |
22 | 28 |
{ |
23 | 29 |
"package": "silex/silex", |
24 | 30 |
"version": "dev-master", |
25 |
- "source-reference": "ad563dde113092aa603e2b399d10ea43aece8006", |
|
26 |
- "commit-date": "1347084669" |
|
31 |
+ "source-reference": "a9e34f08ab00c4cc6c97e7ae8fdf7d0fc367e5f5", |
|
32 |
+ "commit-date": "1347298149" |
|
27 | 33 |
}, |
28 | 34 |
{ |
29 | 35 |
"package": "symfony/event-dispatcher", |
30 | 36 |
"version": "2.1.x-dev", |
31 |
- "source-reference": "v2.1.0-RC2", |
|
32 |
- "commit-date": "1345643321" |
|
37 |
+ "source-reference": "v2.1.1", |
|
38 |
+ "commit-date": "1347274422" |
|
33 | 39 |
}, |
34 | 40 |
{ |
35 | 41 |
"package": "symfony/filesystem", |
... | ... |
@@ -40,26 +46,32 @@ |
40 | 46 |
{ |
41 | 47 |
"package": "symfony/http-foundation", |
42 | 48 |
"version": "2.1.x-dev", |
43 |
- "source-reference": "v2.1.0", |
|
49 |
+ "source-reference": "v2.1.1", |
|
44 | 50 |
"commit-date": "1346761482" |
45 | 51 |
}, |
46 | 52 |
{ |
47 | 53 |
"package": "symfony/http-kernel", |
48 | 54 |
"version": "2.1.x-dev", |
49 |
- "source-reference": "ec5cdb100c20537e9d806facd4d121c985658e8b", |
|
50 |
- "commit-date": "1346926323" |
|
55 |
+ "source-reference": "584499e64026f41c4be938ed35d8f0a9a9eebd38", |
|
56 |
+ "commit-date": "1347354770" |
|
57 |
+ }, |
|
58 |
+ { |
|
59 |
+ "package": "symfony/process", |
|
60 |
+ "version": "2.1.x-dev", |
|
61 |
+ "source-reference": "v2.1.1", |
|
62 |
+ "commit-date": "1346330945" |
|
51 | 63 |
}, |
52 | 64 |
{ |
53 | 65 |
"package": "symfony/routing", |
54 | 66 |
"version": "2.1.x-dev", |
55 |
- "source-reference": "v2.1.0", |
|
56 |
- "commit-date": "1346859854" |
|
67 |
+ "source-reference": "v2.1.1", |
|
68 |
+ "commit-date": "1347274422" |
|
57 | 69 |
}, |
58 | 70 |
{ |
59 | 71 |
"package": "symfony/twig-bridge", |
60 | 72 |
"version": "2.1.x-dev", |
61 |
- "source-reference": "v2.1.0", |
|
62 |
- "commit-date": "1345643321" |
|
73 |
+ "source-reference": "v2.1.1", |
|
74 |
+ "commit-date": "1347274422" |
|
63 | 75 |
}, |
64 | 76 |
{ |
65 | 77 |
"package": "twig/twig", |
... | ... |
@@ -7,8 +7,9 @@ |
7 | 7 |
convertNoticesToExceptions="true" |
8 | 8 |
convertWarningsToExceptions="true" |
9 | 9 |
processIsolation="false" |
10 |
- stopOnFailure="false" |
|
10 |
+ stopOnFailure="true" |
|
11 | 11 |
syntaxCheck="true" |
12 |
+ bootstrap="./vendor/autoload.php" |
|
12 | 13 |
> |
13 | 14 |
<testsuites> |
14 | 15 |
<testsuite name="GitList Test Suite"> |
15 | 16 |
deleted file mode 100644 |
... | ... |
@@ -1,194 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git; |
|
4 |
- |
|
5 |
-use Silex\Application; |
|
6 |
- |
|
7 |
-class Client |
|
8 |
-{ |
|
9 |
- protected $path; |
|
10 |
- protected $hidden; |
|
11 |
- |
|
12 |
- public function __construct($options = null) |
|
13 |
- { |
|
14 |
- $this->setPath($options['path']); |
|
15 |
- $this->setHidden($options['hidden']); |
|
16 |
- } |
|
17 |
- |
|
18 |
- /** |
|
19 |
- * Creates a new repository on the specified path |
|
20 |
- * |
|
21 |
- * @param string $path Path where the new repository will be created |
|
22 |
- * @return Repository Instance of Repository |
|
23 |
- */ |
|
24 |
- public function createRepository($path) |
|
25 |
- { |
|
26 |
- if (file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) { |
|
27 |
- throw new \RuntimeException('A GIT repository already exists at ' . $path); |
|
28 |
- } |
|
29 |
- |
|
30 |
- $repository = new Repository($path, $this); |
|
31 |
- |
|
32 |
- return $repository->create(); |
|
33 |
- } |
|
34 |
- |
|
35 |
- /** |
|
36 |
- * Opens a repository at the specified path |
|
37 |
- * |
|
38 |
- * @param string $path Path where the repository is located |
|
39 |
- * @return Repository Instance of Repository |
|
40 |
- */ |
|
41 |
- public function getRepository($path) |
|
42 |
- { |
|
43 |
- if (!file_exists($path) || !file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) { |
|
44 |
- throw new \RuntimeException('There is no GIT repository at ' . $path); |
|
45 |
- } |
|
46 |
- |
|
47 |
- if (in_array($path, $this->getHidden())) { |
|
48 |
- throw new \RuntimeException('You don\'t have access to this repository'); |
|
49 |
- } |
|
50 |
- |
|
51 |
- return new Repository($path, $this); |
|
52 |
- } |
|
53 |
- |
|
54 |
- /** |
|
55 |
- * Searches for valid repositories on the specified path |
|
56 |
- * |
|
57 |
- * @param string $path Path where repositories will be searched |
|
58 |
- * @return array Found repositories, containing their name, path and description |
|
59 |
- */ |
|
60 |
- public function getRepositories($path) |
|
61 |
- { |
|
62 |
- $repositories = $this->recurseDirectory($path); |
|
63 |
- |
|
64 |
- if (empty($repositories)) { |
|
65 |
- throw new \RuntimeException('There are no GIT repositories in ' . $path); |
|
66 |
- } |
|
67 |
- |
|
68 |
- sort($repositories); |
|
69 |
- |
|
70 |
- return $repositories; |
|
71 |
- } |
|
72 |
- |
|
73 |
- private function recurseDirectory($path) |
|
74 |
- { |
|
75 |
- $dir = new \DirectoryIterator($path); |
|
76 |
- |
|
77 |
- $repositories = array(); |
|
78 |
- |
|
79 |
- foreach ($dir as $file) { |
|
80 |
- if ($file->isDot()) { |
|
81 |
- continue; |
|
82 |
- } |
|
83 |
- |
|
84 |
- if (($pos = strrpos($file->getFilename(), '.')) === 0) { |
|
85 |
- continue; |
|
86 |
- } |
|
87 |
- |
|
88 |
- if ($file->isDir()) { |
|
89 |
- $isBare = file_exists($file->getPathname() . '/HEAD'); |
|
90 |
- $isRepository = file_exists($file->getPathname() . '/.git/HEAD'); |
|
91 |
- |
|
92 |
- if ($isRepository || $isBare) { |
|
93 |
- $pathName = str_replace('\\', '/', $file->getPathname()); |
|
94 |
- |
|
95 |
- if (in_array($pathName, $this->getHidden())) { |
|
96 |
- continue; |
|
97 |
- } |
|
98 |
- |
|
99 |
- if ($isBare) { |
|
100 |
- $description = $file->getPathname() . '/description'; |
|
101 |
- } else { |
|
102 |
- $description = $file->getPathname() . '/.git/description'; |
|
103 |
- } |
|
104 |
- |
|
105 |
- if (file_exists($description)) { |
|
106 |
- $description = file_get_contents($description); |
|
107 |
- } else { |
|
108 |
- $description = 'There is no repository description file. Please, create one to remove this message.'; |
|
109 |
- } |
|
110 |
- |
|
111 |
- $repositories[] = array('name' => $file->getFilename(), 'path' => $pathName, 'description' => $description); |
|
112 |
- continue; |
|
113 |
- } |
|
114 |
- } |
|
115 |
- } |
|
116 |
- |
|
117 |
- return $repositories; |
|
118 |
- } |
|
119 |
- |
|
120 |
- /** |
|
121 |
- * Execute a git command on the repository being manipulated |
|
122 |
- * |
|
123 |
- * This method will start a new process on the current machine and |
|
124 |
- * run git commands. Once the command has been run, the method will |
|
125 |
- * return the command line output. |
|
126 |
- * |
|
127 |
- * @param Repository $repository Repository where the command will be run |
|
128 |
- * @param string $command Git command to be run |
|
129 |
- * @return string Returns the command output |
|
130 |
- */ |
|
131 |
- public function run(Repository $repository, $command) |
|
132 |
- { |
|
133 |
- $descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); |
|
134 |
- $process = proc_open($this->getPath() . ' -c "color.ui"=false ' . $command, $descriptors, $pipes, $repository->getPath()); |
|
135 |
- |
|
136 |
- if (!is_resource($process)) { |
|
137 |
- throw new \RuntimeException('Unable to execute command: ' . $command); |
|
138 |
- } |
|
139 |
- |
|
140 |
- $stdout = stream_get_contents($pipes[1]); |
|
141 |
- fclose($pipes[1]); |
|
142 |
- |
|
143 |
- $stderr = stream_get_contents($pipes[2]); |
|
144 |
- fclose($pipes[2]); |
|
145 |
- |
|
146 |
- $status = proc_close($process); |
|
147 |
- |
|
148 |
- if ($status != 0) { |
|
149 |
- throw new \RuntimeException($stderr); |
|
150 |
- } |
|
151 |
- |
|
152 |
- return $stdout; |
|
153 |
- } |
|
154 |
- |
|
155 |
- /** |
|
156 |
- * Get the current Git binary path |
|
157 |
- * |
|
158 |
- * @return string Path where the Git binary is located |
|
159 |
- */ |
|
160 |
- protected function getPath() |
|
161 |
- { |
|
162 |
- return $this->path; |
|
163 |
- } |
|
164 |
- |
|
165 |
- /** |
|
166 |
- * Set the current Git binary path |
|
167 |
- * |
|
168 |
- * @param string $path Path where the Git binary is located |
|
169 |
- */ |
|
170 |
- protected function setPath($path) |
|
171 |
- { |
|
172 |
- $this->path = $path; |
|
173 |
- } |
|
174 |
- |
|
175 |
- /** |
|
176 |
- * Get hidden repository list |
|
177 |
- * |
|
178 |
- * @return array List of repositories to hide |
|
179 |
- */ |
|
180 |
- protected function getHidden() |
|
181 |
- { |
|
182 |
- return $this->hidden; |
|
183 |
- } |
|
184 |
- |
|
185 |
- /** |
|
186 |
- * Set the hidden repository list |
|
187 |
- * |
|
188 |
- * @param array $hidden List of repositories to hide |
|
189 |
- */ |
|
190 |
- protected function setHidden($hidden) |
|
191 |
- { |
|
192 |
- $this->hidden = $hidden; |
|
193 |
- } |
|
194 |
-} |
195 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,35 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Commit; |
|
4 |
- |
|
5 |
-class Author |
|
6 |
-{ |
|
7 |
- protected $name; |
|
8 |
- protected $email; |
|
9 |
- |
|
10 |
- public function __construct($name, $email) |
|
11 |
- { |
|
12 |
- $this->setName($name); |
|
13 |
- $this->setEmail($email); |
|
14 |
- } |
|
15 |
- |
|
16 |
- public function getName() |
|
17 |
- { |
|
18 |
- return $this->name; |
|
19 |
- } |
|
20 |
- |
|
21 |
- public function setName($name) |
|
22 |
- { |
|
23 |
- $this->name = $name; |
|
24 |
- } |
|
25 |
- |
|
26 |
- public function getEmail() |
|
27 |
- { |
|
28 |
- return $this->email; |
|
29 |
- } |
|
30 |
- |
|
31 |
- public function setEmail($email) |
|
32 |
- { |
|
33 |
- $this->email = $email; |
|
34 |
- } |
|
35 |
-} |
36 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,148 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Commit; |
|
4 |
- |
|
5 |
-class Commit |
|
6 |
-{ |
|
7 |
- protected $hash; |
|
8 |
- protected $shortHash; |
|
9 |
- protected $treeHash; |
|
10 |
- protected $parentHash; |
|
11 |
- protected $author; |
|
12 |
- protected $date; |
|
13 |
- protected $commiter; |
|
14 |
- protected $commiterDate; |
|
15 |
- protected $message; |
|
16 |
- protected $diffs; |
|
17 |
- |
|
18 |
- public function importData(array $data) |
|
19 |
- { |
|
20 |
- $this->setHash($data['hash']); |
|
21 |
- $this->setShortHash($data['short_hash']); |
|
22 |
- $this->setTreeHash($data['tree']); |
|
23 |
- $this->setParentHash($data['parent']); |
|
24 |
- |
|
25 |
- $this->setAuthor( |
|
26 |
- new Author($data['author'], $data['author_email']) |
|
27 |
- ); |
|
28 |
- |
|
29 |
- $this->setDate( |
|
30 |
- new \DateTime('@' . $data['date']) |
|
31 |
- ); |
|
32 |
- |
|
33 |
- $this->setCommiter( |
|
34 |
- new Author($data['commiter'], $data['commiter_email']) |
|
35 |
- ); |
|
36 |
- |
|
37 |
- $this->setCommiterDate( |
|
38 |
- new \DateTime('@' . $data['commiter_date']) |
|
39 |
- ); |
|
40 |
- |
|
41 |
- $this->setMessage($data['message']); |
|
42 |
- } |
|
43 |
- |
|
44 |
- public function getHash() |
|
45 |
- { |
|
46 |
- return $this->hash; |
|
47 |
- } |
|
48 |
- |
|
49 |
- public function setHash($hash) |
|
50 |
- { |
|
51 |
- $this->hash = $hash; |
|
52 |
- } |
|
53 |
- |
|
54 |
- public function getShortHash() |
|
55 |
- { |
|
56 |
- return $this->shortHash; |
|
57 |
- } |
|
58 |
- |
|
59 |
- public function setShortHash($shortHash) |
|
60 |
- { |
|
61 |
- $this->shortHash = $shortHash; |
|
62 |
- } |
|
63 |
- |
|
64 |
- public function getTreeHash() |
|
65 |
- { |
|
66 |
- return $this->treeHash; |
|
67 |
- } |
|
68 |
- |
|
69 |
- public function setTreeHash($treeHash) |
|
70 |
- { |
|
71 |
- $this->treeHash = $treeHash; |
|
72 |
- } |
|
73 |
- |
|
74 |
- public function getParentHash() |
|
75 |
- { |
|
76 |
- return $this->parentHash; |
|
77 |
- } |
|
78 |
- |
|
79 |
- public function setParentHash($parentHash) |
|
80 |
- { |
|
81 |
- $this->parentHash = $parentHash; |
|
82 |
- } |
|
83 |
- |
|
84 |
- public function getAuthor() |
|
85 |
- { |
|
86 |
- return $this->author; |
|
87 |
- } |
|
88 |
- |
|
89 |
- public function setAuthor($author) |
|
90 |
- { |
|
91 |
- $this->author = $author; |
|
92 |
- } |
|
93 |
- |
|
94 |
- public function getDate() |
|
95 |
- { |
|
96 |
- return $this->date; |
|
97 |
- } |
|
98 |
- |
|
99 |
- public function setDate($date) |
|
100 |
- { |
|
101 |
- $this->date = $date; |
|
102 |
- } |
|
103 |
- |
|
104 |
- public function getCommiter() |
|
105 |
- { |
|
106 |
- return $this->commiter; |
|
107 |
- } |
|
108 |
- |
|
109 |
- public function setCommiter($commiter) |
|
110 |
- { |
|
111 |
- $this->commiter = $commiter; |
|
112 |
- } |
|
113 |
- |
|
114 |
- public function getCommiterDate() |
|
115 |
- { |
|
116 |
- return $this->commiterDate; |
|
117 |
- } |
|
118 |
- |
|
119 |
- public function setCommiterDate($commiterDate) |
|
120 |
- { |
|
121 |
- $this->commiterDate = $commiterDate; |
|
122 |
- } |
|
123 |
- |
|
124 |
- public function getMessage() |
|
125 |
- { |
|
126 |
- return $this->message; |
|
127 |
- } |
|
128 |
- |
|
129 |
- public function setMessage($message) |
|
130 |
- { |
|
131 |
- $this->message = $message; |
|
132 |
- } |
|
133 |
- |
|
134 |
- public function getDiffs() |
|
135 |
- { |
|
136 |
- return $this->diffs; |
|
137 |
- } |
|
138 |
- |
|
139 |
- public function setDiffs($diffs) |
|
140 |
- { |
|
141 |
- $this->diffs = $diffs; |
|
142 |
- } |
|
143 |
- |
|
144 |
- public function getChangedFiles() |
|
145 |
- { |
|
146 |
- return sizeof($this->diffs); |
|
147 |
- } |
|
148 |
-} |
149 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,69 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Model; |
|
4 |
- |
|
5 |
-use GitList\Component\Git\Client; |
|
6 |
-use GitList\Component\Git\Repository; |
|
7 |
-use GitList\Component\Git\ScopeAware; |
|
8 |
- |
|
9 |
-class Blob extends ScopeAware |
|
10 |
-{ |
|
11 |
- protected $mode; |
|
12 |
- protected $hash; |
|
13 |
- protected $name; |
|
14 |
- protected $size; |
|
15 |
- |
|
16 |
- public function __construct($hash, Client $client, Repository $repository) |
|
17 |
- { |
|
18 |
- $this->setClient($client); |
|
19 |
- $this->setRepository($repository); |
|
20 |
- $this->setHash($hash); |
|
21 |
- } |
|
22 |
- |
|
23 |
- public function output() |
|
24 |
- { |
|
25 |
- $data = $this->getClient()->run($this->getRepository(), 'show ' . $this->getHash()); |
|
26 |
- |
|
27 |
- return $data; |
|
28 |
- } |
|
29 |
- |
|
30 |
- public function getMode() |
|
31 |
- { |
|
32 |
- return $this->mode; |
|
33 |
- } |
|
34 |
- |
|
35 |
- public function setMode($mode) |
|
36 |
- { |
|
37 |
- $this->mode = $mode; |
|
38 |
- } |
|
39 |
- |
|
40 |
- public function getHash() |
|
41 |
- { |
|
42 |
- return $this->hash; |
|
43 |
- } |
|
44 |
- |
|
45 |
- public function setHash($hash) |
|
46 |
- { |
|
47 |
- $this->hash = $hash; |
|
48 |
- } |
|
49 |
- |
|
50 |
- public function getName() |
|
51 |
- { |
|
52 |
- return $this->name; |
|
53 |
- } |
|
54 |
- |
|
55 |
- public function setName($name) |
|
56 |
- { |
|
57 |
- $this->name = $name; |
|
58 |
- } |
|
59 |
- |
|
60 |
- public function getSize() |
|
61 |
- { |
|
62 |
- return $this->size; |
|
63 |
- } |
|
64 |
- |
|
65 |
- public function setSize($size) |
|
66 |
- { |
|
67 |
- $this->size = $size; |
|
68 |
- } |
|
69 |
-} |
70 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,64 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Model; |
|
4 |
- |
|
5 |
-use GitList\Component\Git\Model\DiffLine; |
|
6 |
- |
|
7 |
-class Diff |
|
8 |
-{ |
|
9 |
- protected $lines; |
|
10 |
- protected $index; |
|
11 |
- protected $old; |
|
12 |
- protected $new; |
|
13 |
- protected $file; |
|
14 |
- |
|
15 |
- public function addLine($line, $oldNo, $newNo) |
|
16 |
- { |
|
17 |
- $this->lines[] = new DiffLine($line, $oldNo, $newNo); |
|
18 |
- } |
|
19 |
- |
|
20 |
- public function getLines() |
|
21 |
- { |
|
22 |
- return $this->lines; |
|
23 |
- } |
|
24 |
- |
|
25 |
- public function setIndex($index) |
|
26 |
- { |
|
27 |
- $this->index = $index; |
|
28 |
- } |
|
29 |
- |
|
30 |
- public function getIndex() |
|
31 |
- { |
|
32 |
- return $this->index; |
|
33 |
- } |
|
34 |
- |
|
35 |
- public function setOld($old) |
|
36 |
- { |
|
37 |
- $this->old = $old; |
|
38 |
- } |
|
39 |
- |
|
40 |
- public function getOld() |
|
41 |
- { |
|
42 |
- return $this->old; |
|
43 |
- } |
|
44 |
- |
|
45 |
- public function setNew($new) |
|
46 |
- { |
|
47 |
- $this->new = $new; |
|
48 |
- } |
|
49 |
- |
|
50 |
- public function getNew() |
|
51 |
- { |
|
52 |
- return $this->new; |
|
53 |
- } |
|
54 |
- |
|
55 |
- public function setFile($file) |
|
56 |
- { |
|
57 |
- $this->file = $file; |
|
58 |
- } |
|
59 |
- |
|
60 |
- public function getFile() |
|
61 |
- { |
|
62 |
- return $this->file; |
|
63 |
- } |
|
64 |
-} |
65 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,59 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Model; |
|
4 |
- |
|
5 |
-use GitList\Component\Git\Model\Line; |
|
6 |
- |
|
7 |
-class DiffLine extends Line |
|
8 |
-{ |
|
9 |
- protected $numNew; |
|
10 |
- protected $numOld; |
|
11 |
- |
|
12 |
- public function __construct($data, $numOld, $numNew) |
|
13 |
- { |
|
14 |
- parent::__construct($data); |
|
15 |
- |
|
16 |
- if (!empty($data)) { |
|
17 |
- switch ($data[0]) { |
|
18 |
- case '@': |
|
19 |
- $this->numOld = '...'; |
|
20 |
- $this->numNew = '...'; |
|
21 |
- break; |
|
22 |
- case '-': |
|
23 |
- $this->numOld = $numOld; |
|
24 |
- $this->numNew = ''; |
|
25 |
- break; |
|
26 |
- case '+': |
|
27 |
- $this->numOld = ''; |
|
28 |
- $this->numNew = $numNew; |
|
29 |
- break; |
|
30 |
- default: |
|
31 |
- $this->numOld = $numOld; |
|
32 |
- $this->numNew = $numNew; |
|
33 |
- } |
|
34 |
- } else { |
|
35 |
- $this->numOld = $numOld; |
|
36 |
- $this->numNew = $numNew; |
|
37 |
- } |
|
38 |
- } |
|
39 |
- |
|
40 |
- public function getNumOld() |
|
41 |
- { |
|
42 |
- return $this->numOld; |
|
43 |
- } |
|
44 |
- |
|
45 |
- public function setNumOld($num) |
|
46 |
- { |
|
47 |
- $this->numOld = $num; |
|
48 |
- } |
|
49 |
- |
|
50 |
- public function getNumNew() |
|
51 |
- { |
|
52 |
- return $this->numNew; |
|
53 |
- } |
|
54 |
- |
|
55 |
- public function setNumNew($num) |
|
56 |
- { |
|
57 |
- $this->numNew = $num; |
|
58 |
- } |
|
59 |
-} |
60 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,48 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Model; |
|
4 |
- |
|
5 |
-class Line |
|
6 |
-{ |
|
7 |
- protected $line; |
|
8 |
- protected $type; |
|
9 |
- |
|
10 |
- public function __construct($data) |
|
11 |
- { |
|
12 |
- if (!empty($data)) { |
|
13 |
- if ($data[0] == '@') { |
|
14 |
- $this->setType('chunk'); |
|
15 |
- } |
|
16 |
- |
|
17 |
- if ($data[0] == '-') { |
|
18 |
- $this->setType('old'); |
|
19 |
- } |
|
20 |
- |
|
21 |
- if ($data[0] == '+') { |
|
22 |
- $this->setType('new'); |
|
23 |
- } |
|
24 |
- } |
|
25 |
- |
|
26 |
- $this->setLine($data); |
|
27 |
- } |
|
28 |
- |
|
29 |
- public function getLine() |
|
30 |
- { |
|
31 |
- return $this->line; |
|
32 |
- } |
|
33 |
- |
|
34 |
- public function setLine($line) |
|
35 |
- { |
|
36 |
- $this->line = $line; |
|
37 |
- } |
|
38 |
- |
|
39 |
- public function getType() |
|
40 |
- { |
|
41 |
- return $this->type; |
|
42 |
- } |
|
43 |
- |
|
44 |
- public function setType($type) |
|
45 |
- { |
|
46 |
- $this->type = $type; |
|
47 |
- } |
|
48 |
-} |
49 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,40 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Model; |
|
4 |
- |
|
5 |
-class Symlink |
|
6 |
-{ |
|
7 |
- protected $mode; |
|
8 |
- protected $name; |
|
9 |
- protected $path; |
|
10 |
- |
|
11 |
- public function getMode() |
|
12 |
- { |
|
13 |
- return $this->mode; |
|
14 |
- } |
|
15 |
- |
|
16 |
- public function setMode($mode) |
|
17 |
- { |
|
18 |
- $this->mode = $mode; |
|
19 |
- } |
|
20 |
- |
|
21 |
- public function getName() |
|
22 |
- { |
|
23 |
- return $this->name; |
|
24 |
- } |
|
25 |
- |
|
26 |
- public function setName($name) |
|
27 |
- { |
|
28 |
- $this->name = $name; |
|
29 |
- } |
|
30 |
- |
|
31 |
- public function getPath() |
|
32 |
- { |
|
33 |
- return $this->path; |
|
34 |
- } |
|
35 |
- |
|
36 |
- public function setPath($path) |
|
37 |
- { |
|
38 |
- $this->path = $path; |
|
39 |
- } |
|
40 |
-} |
41 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,180 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git\Model; |
|
4 |
- |
|
5 |
-use GitList\Component\Git\Client; |
|
6 |
-use GitList\Component\Git\Repository; |
|
7 |
-use GitList\Component\Git\ScopeAware; |
|
8 |
- |
|
9 |
-class Tree extends ScopeAware implements \RecursiveIterator |
|
10 |
-{ |
|
11 |
- protected $mode; |
|
12 |
- protected $hash; |
|
13 |
- protected $name; |
|
14 |
- protected $data; |
|
15 |
- protected $position = 0; |
|
16 |
- |
|
17 |
- public function __construct($hash, Client $client, Repository $repository) |
|
18 |
- { |
|
19 |
- $this->setClient($client); |
|
20 |
- $this->setRepository($repository); |
|
21 |
- $this->setHash($hash); |
|
22 |
- } |
|
23 |
- |
|
24 |
- public function parse() |
|
25 |
- { |
|
26 |
- $data = $this->getClient()->run($this->getRepository(), 'ls-tree -l ' . $this->getHash()); |
|
27 |
- $lines = explode("\n", $data); |
|
28 |
- $files = array(); |
|
29 |
- $root = array(); |
|
30 |
- |
|
31 |
- foreach ($lines as $key => $line) { |
|
32 |
- if (empty($line)) { |
|
33 |
- unset($lines[$key]); |
|
34 |
- continue; |
|
35 |
- } |
|
36 |
- |
|
37 |
- $files[] = preg_split("/[\s]+/", $line, 5); |
|
38 |
- } |
|
39 |
- |
|
40 |
- foreach ($files as $file) { |
|
41 |
- if ($file[1] == 'commit') { |
|
42 |
- // submodule |
|
43 |
- continue; |
|
44 |
- } |
|
45 |
- |
|
46 |
- if ($file[0] == '120000') { |
|
47 |
- $show = $this->getClient()->run($this->getRepository(), 'show ' . $file[2]); |
|
48 |
- $tree = new Symlink; |
|
49 |
- $tree->setMode($file[0]); |
|
50 |
- $tree->setName($file[4]); |
|
51 |
- $tree->setPath($show); |
|
52 |
- $root[] = $tree; |
|
53 |
- continue; |
|
54 |
- } |
|
55 |
- |
|
56 |
- if ($file[1] == 'blob') { |
|
57 |
- $blob = new Blob($file[2], $this->getClient(), $this->getRepository()); |
|
58 |
- $blob->setMode($file[0]); |
|
59 |
- $blob->setName($file[4]); |
|
60 |
- $blob->setSize($file[3]); |
|
61 |
- $root[] = $blob; |
|
62 |
- continue; |
|
63 |
- } |
|
64 |
- |
|
65 |
- $tree = new Tree($file[2], $this->getClient(), $this->getRepository()); |
|
66 |
- $tree->setMode($file[0]); |
|
67 |
- $tree->setName($file[4]); |
|
68 |
- $root[] = $tree; |
|
69 |
- } |
|
70 |
- |
|
71 |
- $this->data = $root; |
|
72 |
- } |
|
73 |
- |
|
74 |
- public function output() |
|
75 |
- { |
|
76 |
- $files = $folders = array(); |
|
77 |
- |
|
78 |
- foreach ($this as $node) { |
|
79 |
- if ($node instanceof Blob) { |
|
80 |
- $file['type'] = 'blob'; |
|
81 |
- $file['name'] = $node->getName(); |
|
82 |
- $file['size'] = $node->getSize(); |
|
83 |
- $file['mode'] = $node->getMode(); |
|
84 |
- $file['hash'] = $node->getHash(); |
|
85 |
- $files[] = $file; |
|
86 |
- continue; |
|
87 |
- } |
|
88 |
- |
|
89 |
- if ($node instanceof Tree) { |
|
90 |
- $folder['type'] = 'folder'; |
|
91 |
- $folder['name'] = $node->getName(); |
|
92 |
- $folder['size'] = ''; |
|
93 |
- $folder['mode'] = $node->getMode(); |
|
94 |
- $folder['hash'] = $node->getHash(); |
|
95 |
- $folders[] = $folder; |
|
96 |
- continue; |
|
97 |
- } |
|
98 |
- |
|
99 |
- if ($node instanceof Symlink) { |
|
100 |
- $folder['type'] = 'symlink'; |
|
101 |
- $folder['name'] = $node->getName(); |
|
102 |
- $folder['size'] = ''; |
|
103 |
- $folder['mode'] = $node->getMode(); |
|
104 |
- $folder['hash'] = ''; |
|
105 |
- $folder['path'] = $node->getPath(); |
|
106 |
- $folders[] = $folder; |
|
107 |
- } |
|
108 |
- } |
|
109 |
- |
|
110 |
- // Little hack to make folders appear before files |
|
111 |
- $files = array_merge($folders, $files); |
|
112 |
- |
|
113 |
- return $files; |
|
114 |
- } |
|
115 |
- |
|
116 |
- public function valid() |
|
117 |
- { |
|
118 |
- return isset($this->data[$this->position]); |
|
119 |
- } |
|
120 |
- |
|
121 |
- public function hasChildren() |
|
122 |
- { |
|
123 |
- return is_array($this->data[$this->position]); |
|
124 |
- } |
|
125 |
- |
|
126 |
- public function next() |
|
127 |
- { |
|
128 |
- $this->position++; |
|
129 |
- } |
|
130 |
- |
|
131 |
- public function current() |
|
132 |
- { |
|
133 |
- return $this->data[$this->position]; |
|
134 |
- } |
|
135 |
- |
|
136 |
- public function getChildren() |
|
137 |
- { |
|
138 |
- return $this->data[$this->position]; |
|
139 |
- } |
|
140 |
- |
|
141 |
- public function rewind() |
|
142 |
- { |
|
143 |
- $this->position = 0; |
|
144 |
- } |
|
145 |
- |
|
146 |
- public function key() |
|
147 |
- { |
|
148 |
- return $this->position; |
|
149 |
- } |
|
150 |
- |
|
151 |
- public function getMode() |
|
152 |
- { |
|
153 |
- return $this->mode; |
|
154 |
- } |
|
155 |
- |
|
156 |
- public function setMode($mode) |
|
157 |
- { |
|
158 |
- $this->mode = $mode; |
|
159 |
- } |
|
160 |
- |
|
161 |
- public function getHash() |
|
162 |
- { |
|
163 |
- return $this->hash; |
|
164 |
- } |
|
165 |
- |
|
166 |
- public function setHash($hash) |
|
167 |
- { |
|
168 |
- $this->hash = $hash; |
|
169 |
- } |
|
170 |
- |
|
171 |
- public function getName() |
|
172 |
- { |
|
173 |
- return $this->name; |
|
174 |
- } |
|
175 |
- |
|
176 |
- public function setName($name) |
|
177 |
- { |
|
178 |
- $this->name = $name; |
|
179 |
- } |
|
180 |
-} |
181 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,615 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git; |
|
4 |
- |
|
5 |
-use GitList\Component\Git\Commit\Commit; |
|
6 |
-use GitList\Component\Git\Model\Tree; |
|
7 |
-use GitList\Component\Git\Model\Blob; |
|
8 |
-use GitList\Component\Git\Model\Diff; |
|
9 |
-use Symfony\Component\Filesystem\Filesystem; |
|
10 |
- |
|
11 |
-class Repository |
|
12 |
-{ |
|
13 |
- protected $path; |
|
14 |
- protected $client; |
|
15 |
- |
|
16 |
- public function __construct($path, Client $client) |
|
17 |
- { |
|
18 |
- $this->setPath($path); |
|
19 |
- $this->setClient($client); |
|
20 |
- } |
|
21 |
- |
|
22 |
- public function setClient(Client $client) |
|
23 |
- { |
|
24 |
- $this->client = $client; |
|
25 |
- } |
|
26 |
- |
|
27 |
- public function getClient() |
|
28 |
- { |
|
29 |
- return $this->client; |
|
30 |
- } |
|
31 |
- |
|
32 |
- public function create() |
|
33 |
- { |
|
34 |
- mkdir($this->getPath()); |
|
35 |
- $this->getClient()->run($this, 'init'); |
|
36 |
- |
|
37 |
- return $this; |
|
38 |
- } |
|
39 |
- |
|
40 |
- public function getConfig($key) |
|
41 |
- { |
|
42 |
- $key = $this->getClient()->run($this, 'config ' . $key); |
|
43 |
- |
|
44 |
- return trim($key); |
|
45 |
- } |
|
46 |
- |
|
47 |
- public function setConfig($key, $value) |
|
48 |
- { |
|
49 |
- $this->getClient()->run($this, "config $key \"$value\""); |
|
50 |
- |
|
51 |
- return $this; |
|
52 |
- } |
|
53 |
- |
|
54 |
- /** |
|
55 |
- * Add untracked files |
|
56 |
- * |
|
57 |
- * @access public |
|
58 |
- * @param mixed $files Files to be added to the repository |
|
59 |
- */ |
|
60 |
- public function add($files = '.') |
|
61 |
- { |
|
62 |
- if (is_array($files)) { |
|
63 |
- $files = implode(' ', $files); |
|
64 |
- } |
|
65 |
- |
|
66 |
- $this->getClient()->run($this, "add $files"); |
|
67 |
- |
|
68 |
- return $this; |
|
69 |
- } |
|
70 |
- |
|
71 |
- /** |
|
72 |
- * Add all untracked files |
|
73 |
- * |
|
74 |
- * @access public |
|
75 |
- */ |
|
76 |
- public function addAll() |
|
77 |
- { |
|
78 |
- $this->getClient()->run($this, "add -A"); |
|
79 |
- |
|
80 |
- return $this; |
|
81 |
- } |
|
82 |
- |
|
83 |
- /** |
|
84 |
- * Commit changes to the repository |
|
85 |
- * |
|
86 |
- * @access public |
|
87 |
- * @param string $message Description of the changes made |
|
88 |
- */ |
|
89 |
- public function commit($message) |
|
90 |
- { |
|
91 |
- $this->getClient()->run($this, "commit -m \"$message\""); |
|
92 |
- |
|
93 |
- return $this; |
|
94 |
- } |
|
95 |
- |
|
96 |
- /** |
|
97 |
- * Checkout a branch |
|
98 |
- * |
|
99 |
- * @access public |
|
100 |
- * @param string $branch Branch to be checked out |
|
101 |
- */ |
|
102 |
- public function checkout($branch) |
|
103 |
- { |
|
104 |
- $this->getClient()->run($this, "checkout $branch"); |
|
105 |
- |
|
106 |
- return $this; |
|
107 |
- } |
|
108 |
- |
|
109 |
- /** |
|
110 |
- * Pull repository changes |
|
111 |
- * |
|
112 |
- * @access public |
|
113 |
- */ |
|
114 |
- public function pull() |
|
115 |
- { |
|
116 |
- $this->getClient()->run($this, "pull"); |
|
117 |
- |
|
118 |
- return $this; |
|
119 |
- } |
|
120 |
- |
|
121 |
- /** |
|
122 |
- * Update remote references |
|
123 |
- * |
|
124 |
- * @access public |
|
125 |
- * @param string $repository Repository to be pushed |
|
126 |
- * @param string $refspec Refspec for the push |
|
127 |
- */ |
|
128 |
- public function push($repository = null, $refspec = null) |
|
129 |
- { |
|
130 |
- $command = "push"; |
|
131 |
- |
|
132 |
- if ($repository) { |
|
133 |
- $command .= " $repository"; |
|
134 |
- } |
|
135 |
- |
|
136 |
- if ($refspec) { |
|
137 |
- $command .= " $refspec"; |
|
138 |
- } |
|
139 |
- |
|
140 |
- $this->getClient()->run($this, $command); |
|
141 |
- |
|
142 |
- return $this; |
|
143 |
- } |
|
144 |
- |
|
145 |
- /** |
|
146 |
- * Show a list of the repository branches |
|
147 |
- * |
|
148 |
- * @access public |
|
149 |
- * @return array List of branches |
|
150 |
- */ |
|
151 |
- public function getBranches() |
|
152 |
- { |
|
153 |
- $branches = $this->getClient()->run($this, "branch"); |
|
154 |
- $branches = explode("\n", $branches); |
|
155 |
- $branches = array_filter(preg_replace('/[\*\s]/', '', $branches)); |
|
156 |
- |
|
157 |
- return $branches; |
|
158 |
- } |
|
159 |
- |
|
160 |
- /** |
|
161 |
- * Show the current repository branch |
|
162 |
- * |
|
163 |
- * @access public |
|
164 |
- * @return string Current repository branch |
|
165 |
- */ |
|
166 |
- public function getCurrentBranch() |
|
167 |
- { |
|
168 |
- $branches = $this->getClient()->run($this, "branch"); |
|
169 |
- $branches = explode("\n", $branches); |
|
170 |
- |
|
171 |
- foreach ($branches as $branch) { |
|
172 |
- if ($branch[0] == '*') { |
|
173 |
- return substr($branch, 2); |
|
174 |
- } |
|
175 |
- } |
|
176 |
- } |
|
177 |
- |
|
178 |
- /** |
|
179 |
- * Check if a specified branch exists |
|
180 |
- * |
|
181 |
- * @access public |
|
182 |
- * @param string $branch Branch to be checked |
|
183 |
- * @return boolean True if the branch exists |
|
184 |
- */ |
|
185 |
- public function hasBranch($branch) |
|
186 |
- { |
|
187 |
- $branches = $this->getBranches(); |
|
188 |
- $status = in_array($branch, $branches); |
|
189 |
- |
|
190 |
- return $status; |
|
191 |
- } |
|
192 |
- |
|
193 |
- /** |
|
194 |
- * Create a new repository branch |
|
195 |
- * |
|
196 |
- * @access public |
|
197 |
- * @param string $branch Branch name |
|
198 |
- */ |
|
199 |
- public function createBranch($branch) |
|
200 |
- { |
|
201 |
- $this->getClient()->run($this, "branch $branch"); |
|
202 |
- } |
|
203 |
- |
|
204 |
- /** |
|
205 |
- * Show a list of the repository tags |
|
206 |
- * |
|
207 |
- * @access public |
|
208 |
- * @return array List of tags |
|
209 |
- */ |
|
210 |
- public function getTags() |
|
211 |
- { |
|
212 |
- $tags = $this->getClient()->run($this, "tag"); |
|
213 |
- $tags = explode("\n", $tags); |
|
214 |
- |
|
215 |
- if (empty($tags[0])) { |
|
216 |
- return NULL; |
|
217 |
- } |
|
218 |
- |
|
219 |
- return $tags; |
|
220 |
- } |
|
221 |
- |
|
222 |
- /** |
|
223 |
- * Show the amount of commits on the repository |
|
224 |
- * |
|
225 |
- * @access public |
|
226 |
- * @return integer Total number of commits |
|
227 |
- */ |
|
228 |
- public function getTotalCommits($file = null) |
|
229 |
- { |
|
230 |
- if (defined('PHP_WINDOWS_VERSION_BUILD')) { |
|
231 |
- $command = "rev-list --count --all $file"; |
|
232 |
- } else { |
|
233 |
- $command = "rev-list --all $file | wc -l"; |
|
234 |
- } |
|
235 |
- |
|
236 |
- $commits = $this->getClient()->run($this, $command); |
|
237 |
- |
|
238 |
- return $commits; |
|
239 |
- } |
|
240 |
- |
|
241 |
- /** |
|
242 |
- * Show the repository commit log |
|
243 |
- * |
|
244 |
- * @access public |
|
245 |
- * @return array Commit log |
|
246 |
- */ |
|
247 |
- public function getCommits($file = null, $page = 0) |
|
248 |
- { |
|
249 |
- $page = 15 * $page; |
|
250 |
- $pager = "--skip=$page --max-count=15"; |
|
251 |
- $command = 'log ' . $pager . ' --pretty=format:"\"%h\": {\"hash\": \"%H\", \"short_hash\": \"%h\", \"tree\": \"%T\", \"parent\": \"%P\", \"author\": \"%an\", \"author_email\": \"%ae\", \"date\": \"%at\", \"commiter\": \"%cn\", \"commiter_email\": \"%ce\", \"commiter_date\": \"%ct\", \"message\": \"%f\"}"'; |
|
252 |
- |
|
253 |
- if ($file) { |
|
254 |
- $command .= " $file"; |
|
255 |
- } |
|
256 |
- |
|
257 |
- $logs = $this->getClient()->run($this, $command); |
|
258 |
- |
|
259 |
- if (empty($logs)) { |
|
260 |
- throw new \RuntimeException('No commit log available'); |
|
261 |
- } |
|
262 |
- |
|
263 |
- $logs = str_replace("\n", ',', $logs); |
|
264 |
- $logs = json_decode("{ $logs }", true); |
|
265 |
- |
|
266 |
- foreach ($logs as $log) { |
|
267 |
- $log['message'] = str_replace('-', ' ', $log['message']); |
|
268 |
- $commit = new Commit; |
|
269 |
- $commit->importData($log); |
|
270 |
- $commits[] = $commit; |
|
271 |
- } |
|
272 |
- |
|
273 |
- return $commits; |
|
274 |
- } |
|
275 |
- |
|
276 |
- public function getRelatedCommits($hash) |
|
277 |
- { |
|
278 |
- $logs = $this->getClient()->run($this, 'log --pretty=format:"\"%h\": {\"hash\": \"%H\", \"short_hash\": \"%h\", \"tree\": \"%T\", \"parent\": \"%P\", \"author\": \"%an\", \"author_email\": \"%ae\", \"date\": \"%at\", \"commiter\": \"%cn\", \"commiter_email\": \"%ce\", \"commiter_date\": \"%ct\", \"message\": \"%f\"}"'); |
|
279 |
- |
|
280 |
- if (empty($logs)) { |
|
281 |
- throw new \RuntimeException('No commit log available'); |
|
282 |
- } |
|
283 |
- |
|
284 |
- $logs = str_replace("\n", ',', $logs); |
|
285 |
- $logs = json_decode("{ $logs }", true); |
|
286 |
- |
|
287 |
- foreach ($logs as $log) { |
|
288 |
- $log['message'] = str_replace('-', ' ', $log['message']); |
|
289 |
- $logTree = $this->getClient()->run($this, 'diff-tree -t -r ' . $log['hash']); |
|
290 |
- $lines = explode("\n", $logTree); |
|
291 |
- array_shift($lines); |
|
292 |
- $files = array(); |
|
293 |
- |
|
294 |
- foreach ($lines as $key => $line) { |
|
295 |
- if (empty($line)) { |
|
296 |
- unset($lines[$key]); |
|
297 |
- continue; |
|
298 |
- } |
|
299 |
- |
|
300 |
- $files[] = preg_split("/[\s]+/", $line); |
|
301 |
- } |
|
302 |
- |
|
303 |
- // Now let's find the commits who have our hash within them |
|
304 |
- foreach ($files as $file) { |
|
305 |
- if ($file[1] == 'commit') { |
|
306 |
- continue; |
|
307 |
- } |
|
308 |
- |
|
309 |
- if ($file[3] == $hash) { |
|
310 |
- $commit = new Commit; |
|
311 |
- $commit->importData($log); |
|
312 |
- $commits[] = $commit; |
|
313 |
- break; |
|
314 |
- } |
|
315 |
- } |
|
316 |
- } |
|
317 |
- |
|
318 |
- return $commits; |
|
319 |
- } |
|
320 |
- |
|
321 |
- public function getCommit($commitHash) |
|
322 |
- { |
|
323 |
- $logs = $this->getClient()->run($this, 'show --pretty=format:"{\"hash\": \"%H\", \"short_hash\": \"%h\", \"tree\": \"%T\", \"parent\": \"%P\", \"author\": \"%an\", \"author_email\": \"%ae\", \"date\": \"%at\", \"commiter\": \"%cn\", \"commiter_email\": \"%ce\", \"commiter_date\": \"%ct\", \"message\": \"%f\"}" ' . $commitHash); |
|
324 |
- |
|
325 |
- if (empty($logs)) { |
|
326 |
- throw new \RuntimeException('No commit log available'); |
|
327 |
- } |
|
328 |
- |
|
329 |
- $logs = explode("\n", $logs); |
|
330 |
- |
|
331 |
- // Read commit metadata |
|
332 |
- $data = json_decode($logs[0], true); |
|
333 |
- $data['message'] = str_replace('-', ' ', $data['message']); |
|
334 |
- $commit = new Commit; |
|
335 |
- $commit->importData($data); |
|
336 |
- unset($logs[0]); |
|
337 |
- |
|
338 |
- if (empty($logs[1])) { |
|
339 |
- $logs = explode("\n", $this->getClient()->run($this, 'diff ' . $commitHash . '~1..' . $commitHash)); |
|
340 |
- } |
|
341 |
- |
|
342 |
- // Read diff logs |
|
343 |
- $lineNumOld = 0; |
|
344 |
- $lineNumNew = 0; |
|
345 |
- foreach ($logs as $log) { |
|
346 |
- if ('diff' === substr($log, 0, 4)) { |
|
347 |
- if (isset($diff)) { |
|
348 |
- $diffs[] = $diff; |
|
349 |
- } |
|
350 |
- |
|
351 |
- $diff = new Diff; |
|
352 |
- preg_match('/^diff --[\S]+ (a\/)?([\S]+)( b\/)?/', $log, $name); |
|
353 |
- $diff->setFile($name[2]); |
|
354 |
- continue; |
|
355 |
- } |
|
356 |
- |
|
357 |
- if ('index' === substr($log, 0, 5)) { |
|
358 |
- $diff->setIndex($log); |
|
359 |
- continue; |
|
360 |
- } |
|
361 |
- |
|
362 |
- if ('---' === substr($log, 0, 3)) { |
|
363 |
- $diff->setOld($log); |
|
364 |
- continue; |
|
365 |
- } |
|
366 |
- |
|
367 |
- if ('+++' === substr($log, 0, 3)) { |
|
368 |
- $diff->setNew($log); |
|
369 |
- continue; |
|
370 |
- } |
|
371 |
- |
|
372 |
- // Handle binary files properly. |
|
373 |
- if ('Binary' === substr($log, 0, 6)) { |
|
374 |
- $m = array(); |
|
375 |
- if (preg_match('/Binary files (.+) and (.+) differ/', $log, $m)) { |
|
376 |
- $diff->setOld($m[1]); |
|
377 |
- $diff->setNew(" {$m[2]}"); |
|
378 |
- } |
|
379 |
- } |
|
380 |
- |
|
381 |
- if (!empty($log)) { |
|
382 |
- switch ($log[0]) { |
|
383 |
- case "@": |
|
384 |
- // Set the line numbers |
|
385 |
- preg_match('/@@ -([0-9]+)/', $log, $matches); |
|
386 |
- $lineNumOld = $matches[1] - 1; |
|
387 |
- $lineNumNew = $matches[1] - 1; |
|
388 |
- break; |
|
389 |
- case "-": |
|
390 |
- $lineNumOld++; |
|
391 |
- break; |
|
392 |
- case "+": |
|
393 |
- $lineNumNew++; |
|
394 |
- break; |
|
395 |
- default: |
|
396 |
- $lineNumOld++; |
|
397 |
- $lineNumNew++; |
|
398 |
- } |
|
399 |
- } else { |
|
400 |
- $lineNumOld++; |
|
401 |
- $lineNumNew++; |
|
402 |
- } |
|
403 |
- |
|
404 |
- $diff->addLine($log, $lineNumOld, $lineNumNew); |
|
405 |
- } |
|
406 |
- |
|
407 |
- if (isset($diff)) { |
|
408 |
- $diffs[] = $diff; |
|
409 |
- } |
|
410 |
- |
|
411 |
- $commit->setDiffs($diffs); |
|
412 |
- |
|
413 |
- return $commit; |
|
414 |
- } |
|
415 |
- |
|
416 |
- public function getAuthorStatistics() |
|
417 |
- { |
|
418 |
- $logs = $this->getClient()->run($this, 'log --pretty=format:"%an||%ae" ' . $this->getHead()); |
|
419 |
- |
|
420 |
- if (empty($logs)) { |
|
421 |
- throw new \RuntimeException('No statistics available'); |
|
422 |
- } |
|
423 |
- |
|
424 |
- $logs = explode("\n", $logs); |
|
425 |
- $logs = array_count_values($logs); |
|
426 |
- arsort($logs); |
|
427 |
- |
|
428 |
- foreach ($logs as $user => $count) { |
|
429 |
- $user = explode('||', $user); |
|
430 |
- $data[] = array('name' => $user[0], 'email' => $user[1], 'commits' => $count); |
|
431 |
- } |
|
432 |
- |
|
433 |
- return $data; |
|
434 |
- } |
|
435 |
- |
|
436 |
- /** |
|
437 |
- * Get the current HEAD. |
|
438 |
- * |
|
439 |
- * @return string the name of the HEAD branch. |
|
440 |
- */ |
|
441 |
- public function getHead() |
|
442 |
- { |
|
443 |
- if (file_exists($this->getPath() . '/.git/HEAD')) { |
|
444 |
- $file = @file_get_contents($this->getPath() . '/.git/HEAD'); |
|
445 |
- } elseif (file_exists($this->getPath() . '/HEAD')) { |
|
446 |
- $file = @file_get_contents($this->getPath() . '/HEAD'); |
|
447 |
- } else { |
|
448 |
- return 'master'; |
|
449 |
- } |
|
450 |
- // Find first existing branch |
|
451 |
- foreach (explode("\n", $file) as $line) { |
|
452 |
- $m = array(); |
|
453 |
- if (preg_match('#ref:\srefs/heads/(.+)#', $line, $m)) { |
|
454 |
- if ($this->hasBranch($m[1])) { |
|
455 |
- return $m[1]; |
|
456 |
- } |
|
457 |
- } |
|
458 |
- } |
|
459 |
- |
|
460 |
- // Default to something sane if in a detached HEAD state. |
|
461 |
- $branches = $this->getBranches(); |
|
462 |
- if (!empty($branches)) { |
|
463 |
- return current($branches); |
|
464 |
- } |
|
465 |
- |
|
466 |
- return 'master'; |
|
467 |
- } |
|
468 |
- |
|
469 |
- public function getStatistics($branch) |
|
470 |
- { |
|
471 |
- // Calculate amount of files, extensions and file size |
|
472 |
- $logs = $this->getClient()->run($this, 'ls-tree -r -l ' . $branch); |
|
473 |
- $lines = explode("\n", $logs); |
|
474 |
- $files = array(); |
|
475 |
- $data['extensions'] = array(); |
|
476 |
- $data['size'] = 0; |
|
477 |
- $data['files'] = 0; |
|
478 |
- |
|
479 |
- foreach ($lines as $key => $line) { |
|
480 |
- if (empty($line)) { |
|
481 |
- unset($lines[$key]); |
|
482 |
- continue; |
|
483 |
- } |
|
484 |
- |
|
485 |
- $files[] = preg_split("/[\s]+/", $line); |
|
486 |
- } |
|
487 |
- |
|
488 |
- foreach ($files as $file) { |
|
489 |
- if ($file[1] == 'blob') { |
|
490 |
- $data['files']++; |
|
491 |
- } |
|
492 |
- |
|
493 |
- if (is_numeric($file[3])) { |
|
494 |
- $data['size'] += $file[3]; |
|
495 |
- } |
|
496 |
- |
|
497 |
- if (($pos = strrpos($file[4], '.')) !== FALSE) { |
|
498 |
- $data['extensions'][] = substr($file[4], $pos); |
|
499 |
- } |
|
500 |
- } |
|
501 |
- |
|
502 |
- $data['extensions'] = array_count_values($data['extensions']); |
|
503 |
- arsort($data['extensions']); |
|
504 |
- |
|
505 |
- return $data; |
|
506 |
- } |
|
507 |
- |
|
508 |
- /** |
|
509 |
- * Extract the tree hash for a given branch or tree reference |
|
510 |
- * |
|
511 |
- * @param string $branch |
|
512 |
- * @return string |
|
513 |
- */ |
|
514 |
- public function getBranchTree($branch) |
|
515 |
- { |
|
516 |
- $hash = $this->getClient()->run($this, "log --pretty=\"%T\" --max-count=1 $branch"); |
|
517 |
- $hash = trim($hash, "\r\n "); |
|
518 |
- |
|
519 |
- return $hash ? : false; |
|
520 |
- } |
|
521 |
- |
|
522 |
- /** |
|
523 |
- * Create a TAR or ZIP archive of a git tree |
|
524 |
- * |
|
525 |
- * @param string $tree Tree-ish reference |
|
526 |
- * @param string $output Output File name |
|
527 |
- * @param string $format Archive format |
|
528 |
- */ |
|
529 |
- public function createArchive($tree, $output, $format = 'zip') |
|
530 |
- { |
|
531 |
- $fs = new Filesystem; |
|
532 |
- $fs->mkdir(dirname($output)); |
|
533 |
- $this->getClient()->run($this, "archive --format=$format --output=$output $tree"); |
|
534 |
- } |
|
535 |
- |
|
536 |
- /** |
|
537 |
- * Get the Tree for the provided folder |
|
538 |
- * |
|
539 |
- * @param string $tree Folder that will be parsed |
|
540 |
- * @return Tree Instance of Tree for the provided folder |
|
541 |
- */ |
|
542 |
- public function getTree($tree) |
|
543 |
- { |
|
544 |
- $tree = new Tree($tree, $this->getClient(), $this); |
|
545 |
- $tree->parse(); |
|
546 |
- |
|
547 |
- return $tree; |
|
548 |
- } |
|
549 |
- |
|
550 |
- /** |
|
551 |
- * Get the Blob for the provided file |
|
552 |
- * |
|
553 |
- * @param string $blob File that will be parsed |
|
554 |
- * @return Blob Instance of Blob for the provided file |
|
555 |
- */ |
|
556 |
- public function getBlob($blob) |
|
557 |
- { |
|
558 |
- return new Blob($blob, $this->getClient(), $this); |
|
559 |
- } |
|
560 |
- |
|
561 |
- /** |
|
562 |
- * Blames the provided file and parses the output |
|
563 |
- * |
|
564 |
- * @param string $file File that will be blamed |
|
565 |
- * @return array Commits hashes containing the lines |
|
566 |
- */ |
|
567 |
- public function getBlame($file) |
|
568 |
- { |
|
569 |
- $blame = array(); |
|
570 |
- $logs = $this->getClient()->run($this, "blame -s $file"); |
|
571 |
- $logs = explode("\n", $logs); |
|
572 |
- |
|
573 |
- $i = 0; |
|
574 |
- $previous_commit = ''; |
|
575 |
- foreach ($logs as $log) { |
|
576 |
- if ($log == '') { |
|
577 |
- continue; |
|
578 |
- } |
|
579 |
- |
|
580 |
- preg_match_all("/([a-zA-Z0-9^]{8})\s+.*?([0-9]+)\)(.+)/", $log, $match); |
|
581 |
- |
|
582 |
- $current_commit = $match[1][0]; |
|
583 |
- $current_commit = str_replace('^', '', $current_commit); |
|
584 |
- if ($current_commit != $previous_commit) { |
|
585 |
- ++$i; |
|
586 |
- $blame[$i] = array('line' => '', 'commit' => $current_commit); |
|
587 |
- } |
|
588 |
- |
|
589 |
- $blame[$i]['line'] .= PHP_EOL . $match[3][0]; |
|
590 |
- $previous_commit = $current_commit; |
|
591 |
- } |
|
592 |
- |
|
593 |
- return $blame; |
|
594 |
- } |
|
595 |
- |
|
596 |
- /** |
|
597 |
- * Get the current Repository path |
|
598 |
- * |
|
599 |
- * @return string Path where the repository is located |
|
600 |
- */ |
|
601 |
- public function getPath() |
|
602 |
- { |
|
603 |
- return $this->path; |
|
604 |
- } |
|
605 |
- |
|
606 |
- /** |
|
607 |
- * Set the current Repository path |
|
608 |
- * |
|
609 |
- * @param string $path Path where the repository is located |
|
610 |
- */ |
|
611 |
- public function setPath($path) |
|
612 |
- { |
|
613 |
- $this->path = $path; |
|
614 |
- } |
|
615 |
-} |
616 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,29 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-namespace GitList\Component\Git; |
|
4 |
- |
|
5 |
-class ScopeAware |
|
6 |
-{ |
|
7 |
- protected $client; |
|
8 |
- protected $repository; |
|
9 |
- |
|
10 |
- public function setClient(Client $client) |
|
11 |
- { |
|
12 |
- $this->client = $client; |
|
13 |
- } |
|
14 |
- |
|
15 |
- public function getClient() |
|
16 |
- { |
|
17 |
- return $this->client; |
|
18 |
- } |
|
19 |
- |
|
20 |
- public function getRepository() |
|
21 |
- { |
|
22 |
- return $this->repository; |
|
23 |
- } |
|
24 |
- |
|
25 |
- public function setRepository($repository) |
|
26 |
- { |
|
27 |
- $this->repository = $repository; |
|
28 |
- } |
|
29 |
-} |
... | ... |
@@ -17,7 +17,7 @@ class CommitController implements ControllerProviderInterface |
17 | 17 |
$repository = $app['git']->getRepository($app['git.repos'] . $repo); |
18 | 18 |
$type = $file ? "$branch -- $file" : $branch; |
19 | 19 |
$pager = $app['util.view']->getPager($app['request']->get('page'), $repository->getTotalCommits($type)); |
20 |
- $commits = $repository->getCommits($type, $pager['current']); |
|
20 |
+ $commits = $repository->getPaginatedCommits($type, $pager['current']); |
|
21 | 21 |
|
22 | 22 |
foreach ($commits as $commit) { |
23 | 23 |
$date = $commit->getDate(); |
... | ... |
@@ -41,7 +41,7 @@ class MainController implements ControllerProviderInterface |
41 | 41 |
|
42 | 42 |
$route->get('{repo}/{branch}/rss/', function($repo, $branch) use ($app) { |
43 | 43 |
$repository = $app['git']->getRepository($app['git.repos'] . $repo); |
44 |
- $commits = $repository->getCommits($branch); |
|
44 |
+ $commits = $repository->getPaginatedCommits($branch); |
|
45 | 45 |
|
46 | 46 |
$html = $app['twig']->render('rss.twig', array( |
47 | 47 |
'repo' => $repo, |
48 | 48 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,44 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+namespace GitList\Git; |
|
4 |
+ |
|
5 |
+use Gitter\Client as BaseClient; |
|
6 |
+ |
|
7 |
+class Client extends BaseClient |
|
8 |
+{ |
|
9 |
+ /** |
|
10 |
+ * Creates a new repository on the specified path |
|
11 |
+ * |
|
12 |
+ * @param string $path Path where the new repository will be created |
|
13 |
+ * @return Repository Instance of Repository |
|
14 |
+ */ |
|
15 |
+ public function createRepository($path, $bare = null) |
|
16 |
+ { |
|
17 |
+ if (file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) { |
|
18 |
+ throw new \RuntimeException('A GIT repository already exists at ' . $path); |
|
19 |
+ } |
|
20 |
+ |
|
21 |
+ $repository = new Repository($path, $this); |
|
22 |
+ |
|
23 |
+ return $repository->create($bare); |
|
24 |
+ } |
|
25 |
+ |
|
26 |
+ /** |
|
27 |
+ * Opens a repository at the specified path |
|
28 |
+ * |
|
29 |
+ * @param string $path Path where the repository is located |
|
30 |
+ * @return Repository Instance of Repository |
|
31 |
+ */ |
|
32 |
+ public function getRepository($path) |
|
33 |
+ { |
|
34 |
+ if (!file_exists($path) || !file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) { |
|
35 |
+ throw new \RuntimeException('There is no GIT repository at ' . $path); |
|
36 |
+ } |
|
37 |
+ |
|
38 |
+ if (in_array($path, $this->getHidden())) { |
|
39 |
+ throw new \RuntimeException('You don\'t have access to this repository'); |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ return new Repository($path, $this); |
|
43 |
+ } |
|
44 |
+} |
|
0 | 45 |
\ No newline at end of file |
1 | 46 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,110 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+namespace GitList\Git; |
|
4 |
+ |
|
5 |
+use Gitter\Repository as BaseRepository; |
|
6 |
+use Gitter\Model\Commit\Commit; |
|
7 |
+use Symfony\Component\Filesystem\Filesystem; |
|
8 |
+ |
|
9 |
+class Repository extends BaseRepository |
|
10 |
+{ |
|
11 |
+ /** |
|
12 |
+ * Show the repository commit log with pagination |
|
13 |
+ * |
|
14 |
+ * @access public |
|
15 |
+ * @return array Commit log |
|
16 |
+ */ |
|
17 |
+ public function getPaginatedCommits($file = null, $page = 0) |
|
18 |
+ { |
|
19 |
+ $page = 15 * $page; |
|
20 |
+ $pager = "--skip=$page --max-count=15"; |
|
21 |
+ $command = "log $pager --pretty=format:'<item><hash>%H</hash><short_hash>%h</short_hash><tree>%T</tree><parent>%P</parent><author>%an</author><author_email>%ae</author_email><date>%at</date><commiter>%cn</commiter><commiter_email>%ce</commiter_email><commiter_date>%ct</commiter_date><message><![CDATA[%s]]></message></item>'"; |
|
22 |
+ |
|
23 |
+ if ($file) { |
|
24 |
+ $command .= " $file"; |
|
25 |
+ } |
|
26 |
+ |
|
27 |
+ $logs = $this->getPrettyFormat($command); |
|
28 |
+ |
|
29 |
+ foreach ($logs as $log) { |
|
30 |
+ $commit = new Commit; |
|
31 |
+ $commit->importData($log); |
|
32 |
+ $commits[] = $commit; |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ return $commits; |
|
36 |
+ } |
|
37 |
+ |
|
38 |
+ public function getAuthorStatistics() |
|
39 |
+ { |
|
40 |
+ $logs = $this->getClient()->run($this, 'log --pretty=format:"%an||%ae" ' . $this->getHead()); |
|
41 |
+ |
|
42 |
+ if (empty($logs)) { |
|
43 |
+ throw new \RuntimeException('No statistics available'); |
|
44 |
+ } |
|
45 |
+ |
|
46 |
+ $logs = explode("\n", $logs); |
|
47 |
+ $logs = array_count_values($logs); |
|
48 |
+ arsort($logs); |
|
49 |
+ |
|
50 |
+ foreach ($logs as $user => $count) { |
|
51 |
+ $user = explode('||', $user); |
|
52 |
+ $data[] = array('name' => $user[0], 'email' => $user[1], 'commits' => $count); |
|
53 |
+ } |
|
54 |
+ |
|
55 |
+ return $data; |
|
56 |
+ } |
|
57 |
+ |
|
58 |
+ public function getStatistics($branch) |
|
59 |
+ { |
|
60 |
+ // Calculate amount of files, extensions and file size |
|
61 |
+ $logs = $this->getClient()->run($this, 'ls-tree -r -l ' . $branch); |
|
62 |
+ $lines = explode("\n", $logs); |
|
63 |
+ $files = array(); |
|
64 |
+ $data['extensions'] = array(); |
|
65 |
+ $data['size'] = 0; |
|
66 |
+ $data['files'] = 0; |
|
67 |
+ |
|
68 |
+ foreach ($lines as $key => $line) { |
|
69 |
+ if (empty($line)) { |
|
70 |
+ unset($lines[$key]); |
|
71 |
+ continue; |
|
72 |
+ } |
|
73 |
+ |
|
74 |
+ $files[] = preg_split("/[\s]+/", $line); |
|
75 |
+ } |
|
76 |
+ |
|
77 |
+ foreach ($files as $file) { |
|
78 |
+ if ($file[1] == 'blob') { |
|
79 |
+ $data['files']++; |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ if (is_numeric($file[3])) { |
|
83 |
+ $data['size'] += $file[3]; |
|
84 |
+ } |
|
85 |
+ |
|
86 |
+ if (($pos = strrpos($file[4], '.')) !== FALSE) { |
|
87 |
+ $data['extensions'][] = substr($file[4], $pos); |
|
88 |
+ } |
|
89 |
+ } |
|
90 |
+ |
|
91 |
+ $data['extensions'] = array_count_values($data['extensions']); |
|
92 |
+ arsort($data['extensions']); |
|
93 |
+ |
|
94 |
+ return $data; |
|
95 |
+ } |
|
96 |
+ |
|
97 |
+ /** |
|
98 |
+ * Create a TAR or ZIP archive of a git tree |
|
99 |
+ * |
|
100 |
+ * @param string $tree Tree-ish reference |
|
101 |
+ * @param string $output Output File name |
|
102 |
+ * @param string $format Archive format |
|
103 |
+ */ |
|
104 |
+ public function createArchive($tree, $output, $format = 'zip') |
|
105 |
+ { |
|
106 |
+ $fs = new Filesystem; |
|
107 |
+ $fs->mkdir(dirname($output)); |
|
108 |
+ $this->getClient()->run($this, "archive --format=$format --output=$output $tree"); |
|
109 |
+ } |
|
110 |
+} |
9 | 9 |
deleted file mode 100644 |
... | ... |
@@ -1,133 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-require 'vendor/autoload.php'; |
|
4 |
- |
|
5 |
-use GitList\Component\Git\Client; |
|
6 |
-use GitList\Component\Git\Repository; |
|
7 |
-use Symfony\Component\Filesystem\Filesystem; |
|
8 |
- |
|
9 |
-class ClientTest extends PHPUnit_Framework_TestCase |
|
10 |
-{ |
|
11 |
- protected static $tmpdir; |
|
12 |
- |
|
13 |
- protected $client; |
|
14 |
- |
|
15 |
- public static function setUpBeforeClass() |
|
16 |
- { |
|
17 |
- if (getenv('TMP')) { |
|
18 |
- self::$tmpdir = getenv('TMP'); |
|
19 |
- } elseif (getenv('TMPDIR')) { |
|
20 |
- self::$tmpdir = getenv('TMPDIR'); |
|
21 |
- } else { |
|
22 |
- self::$tmpdir = '/tmp'; |
|
23 |
- } |
|
24 |
- |
|
25 |
- self::$tmpdir .= '/gitlist_' . md5(time() . mt_rand()); |
|
26 |
- |
|
27 |
- $fs = new Filesystem(); |
|
28 |
- $fs->mkdir(self::$tmpdir); |
|
29 |
- |
|
30 |
- if (!is_writable(self::$tmpdir)) { |
|
31 |
- $this->markTestSkipped('There are no write permissions in order to create test repositories.'); |
|
32 |
- } |
|
33 |
- } |
|
34 |
- |
|
35 |
- public function setUp() |
|
36 |
- { |
|
37 |
- if (!is_writable(self::$tmpdir)) { |
|
38 |
- $this->markTestSkipped('There are no write permissions in order to create test repositories.'); |
|
39 |
- } |
|
40 |
- |
|
41 |
- $options['path'] = getenv('GIT_CLIENT') ?: '/usr/bin/git'; |
|
42 |
- $options['hidden'] = array(self::$tmpdir . '/hiddenrepo'); |
|
43 |
- $this->client = new Client($options); |
|
44 |
- } |
|
45 |
- |
|
46 |
- /** |
|
47 |
- * @expectedException RuntimeException |
|
48 |
- */ |
|
49 |
- public function testIsNotFindingRepositories() |
|
50 |
- { |
|
51 |
- $this->client->getRepositories(self::$tmpdir . '/testrepo'); |
|
52 |
- } |
|
53 |
- |
|
54 |
- /** |
|
55 |
- * @expectedException RuntimeException |
|
56 |
- */ |
|
57 |
- public function testIsNotAbleToGetUnexistingRepository() |
|
58 |
- { |
|
59 |
- $this->client->getRepository(self::$tmpdir . '/testrepo'); |
|
60 |
- } |
|
61 |
- |
|
62 |
- /** |
|
63 |
- * @expectedException RuntimeException |
|
64 |
- */ |
|
65 |
- public function testIsNotAbleToGetUnexistingRepositories() |
|
66 |
- { |
|
67 |
- $this->client->getRepositories(self::$tmpdir); |
|
68 |
- } |
|
69 |
- |
|
70 |
- public function testIsCreatingRepository() |
|
71 |
- { |
|
72 |
- $repository = $this->client->createRepository(self::$tmpdir . '/testrepo'); |
|
73 |
- $this->assertRegExp("/nothing to commit/", $repository->getClient()->run($repository, 'status')); |
|
74 |
- } |
|
75 |
- |
|
76 |
- /** |
|
77 |
- * @expectedException RuntimeException |
|
78 |
- */ |
|
79 |
- public function testIsNotAbleToCreateRepositoryDueToExistingOne() |
|
80 |
- { |
|
81 |
- $this->client->createRepository(self::$tmpdir . '/testrepo'); |
|
82 |
- } |
|
83 |
- |
|
84 |
- public function testIsListingRepositories() |
|
85 |
- { |
|
86 |
- $this->client->createRepository(self::$tmpdir . '/anothertestrepo'); |
|
87 |
- $this->client->createRepository(self::$tmpdir . '/bigbadrepo'); |
|
88 |
- $repositories = $this->client->getRepositories(self::$tmpdir); |
|
89 |
- |
|
90 |
- $this->assertEquals($repositories[0]['name'], 'anothertestrepo'); |
|
91 |
- $this->assertEquals($repositories[1]['name'], 'bigbadrepo'); |
|
92 |
- $this->assertEquals($repositories[2]['name'], 'testrepo'); |
|
93 |
- } |
|
94 |
- |
|
95 |
- public function testIsNotListingHiddenRepositories() |
|
96 |
- { |
|
97 |
- $this->client->createRepository(self::$tmpdir . '/hiddenrepo'); |
|
98 |
- $repositories = $this->client->getRepositories(self::$tmpdir); |
|
99 |
- |
|
100 |
- $this->assertEquals($repositories[0]['name'], 'anothertestrepo'); |
|
101 |
- $this->assertEquals($repositories[1]['name'], 'bigbadrepo'); |
|
102 |
- $this->assertEquals($repositories[2]['name'], 'testrepo'); |
|
103 |
- $this->assertFalse(isset($repositories[3])); |
|
104 |
- } |
|
105 |
- |
|
106 |
- /** |
|
107 |
- * @expectedException RuntimeException |
|
108 |
- */ |
|
109 |
- public function testIsNotOpeningHiddenRepositories() |
|
110 |
- { |
|
111 |
- $this->client->getRepository(self::$tmpdir . '/hiddenrepo'); |
|
112 |
- } |
|
113 |
- |
|
114 |
- /** |
|
115 |
- * @expectedException RuntimeException |
|
116 |
- */ |
|
117 |
- public function testIsCatchingGitCommandErrors() |
|
118 |
- { |
|
119 |
- $repository = $this->client->getRepository(self::$tmpdir . '/testrepo'); |
|
120 |
- $repository->getClient()->run($repository, 'wrong'); |
|
121 |
- } |
|
122 |
- |
|
123 |
- public static function tearDownAfterClass() |
|
124 |
- { |
|
125 |
- $fs = new Filesystem(); |
|
126 |
- |
|
127 |
- try { |
|
128 |
- //$fs->remove(self::$tmpdir); |
|
129 |
- } catch (IOException $e) { |
|
130 |
- // Ignore, file is not closed yet |
|
131 |
- } |
|
132 |
- } |
|
133 |
-} |
... | ... |
@@ -1,11 +1,8 @@ |
1 | 1 |
<?php |
2 | 2 |
|
3 |
-require 'vendor/autoload.php'; |
|
4 |
- |
|
5 | 3 |
use Silex\WebTestCase; |
6 | 4 |
use Symfony\Component\Filesystem\Filesystem; |
7 |
-use Symfony\Component\Filesystem\Exception\IOException; |
|
8 |
-use GitList\Component\Git\Client; |
|
5 |
+use Gitter\Client; |
|
9 | 6 |
|
10 | 7 |
class InterfaceTest extends WebTestCase |
11 | 8 |
{ |
... | ... |
@@ -204,11 +201,6 @@ class InterfaceTest extends WebTestCase |
204 | 201 |
public static function tearDownAfterClass() |
205 | 202 |
{ |
206 | 203 |
$fs = new Filesystem(); |
207 |
- |
|
208 |
- try { |
|
209 |
- $fs->remove(self::$tmpdir); |
|
210 |
- } catch (IOException $e) { |
|
211 |
- // Ignore, file is not closed yet |
|
212 |
- } |
|
204 |
+ $fs->remove(self::$tmpdir); |
|
213 | 205 |
} |
214 | 206 |
} |
215 | 207 |
deleted file mode 100644 |
... | ... |
@@ -1,401 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-require 'vendor/autoload.php'; |
|
4 |
- |
|
5 |
-use GitList\Component\Git\Client; |
|
6 |
-use GitList\Component\Git\Repository; |
|
7 |
-use Symfony\Component\Filesystem\Filesystem; |
|
8 |
- |
|
9 |
-class RepositoryTest extends PHPUnit_Framework_TestCase |
|
10 |
-{ |
|
11 |
- protected static $tmpdir; |
|
12 |
- |
|
13 |
- protected $client; |
|
14 |
- |
|
15 |
- public static function setUpBeforeClass() |
|
16 |
- { |
|
17 |
- if (getenv('TMP')) { |
|
18 |
- self::$tmpdir = getenv('TMP'); |
|
19 |
- } elseif (getenv('TMPDIR')) { |
|
20 |
- self::$tmpdir = getenv('TMPDIR'); |
|
21 |
- } else { |
|
22 |
- self::$tmpdir = '/tmp'; |
|
23 |
- } |
|
24 |
- |
|
25 |
- self::$tmpdir .= '/gitlist_' . md5(time() . mt_rand()); |
|
26 |
- |
|
27 |
- $fs = new Filesystem(); |
|
28 |
- $fs->mkdir(self::$tmpdir); |
|
29 |
- |
|
30 |
- if (!is_writable(self::$tmpdir)) { |
|
31 |
- $this->markTestSkipped('There are no write permissions in order to create test repositories.'); |
|
32 |
- } |
|
33 |
- } |
|
34 |
- |
|
35 |
- public function setUp() |
|
36 |
- { |
|
37 |
- if (!is_writable(self::$tmpdir)) { |
|
38 |
- $this->markTestSkipped('There are no write permissions in order to create test repositories.'); |
|
39 |
- } |
|
40 |
- |
|
41 |
- $options['path'] = getenv('GIT_CLIENT') ?: '/usr/bin/git'; |
|
42 |
- $options['hidden'] = array(); |
|
43 |
- $this->client = new Client($options); |
|
44 |
- } |
|
45 |
- |
|