forked from zacharydanger/git-phing
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGitFetchTask.php
More file actions
executable file
·73 lines (59 loc) · 1.09 KB
/
GitFetchTask.php
File metadata and controls
executable file
·73 lines (59 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require_once 'GitTask.php';
/**
* Perform a fetch in git.
* @author Beau Simensen <simensen@gmail.com>
*/
class GitFetchTask extends GitTask {
/**
* Path to cloned repository
* @var string
*/
private $_path = null;
/**
* Tags?
* @var bool
*/
private $_tags = null;
/**
* Sets the target path for the cloned repository.
*/
public function setPath($path) {
$this->_path = $path;
}
/**
* Sets the tags.
*/
public function setTags($tags) {
if ( 'false' == strtolower($tags) or ! $tags ) {
$this->_tags = false;
} else {
$this->_tags = true;
}
}
/**
* Main entry point.
*/
public function main() {
if(false == isset($this->_path)) {
$this->log("GitFetchTask Fail: PATH must be set!\n");
exit(1);
}
$dir = getcwd();
chdir($this->_path);
$cmd = $this->git_path . ' fetch';
if ( $this->_tags ) {
$cmd .= ' --tags';
}
$this->log("Running " . $cmd);
passthru($cmd, $return);
$this->log("Return: " . $return);
chdir($dir);
if(intval($return) > 0) {
if ( intval)
$this->log("Git Fetch Failed.");
exit(1);
}
}
}
?>