summaryrefslogtreecommitdiffstats
path: root/src/GitHubPagesDeploy/GitHubPagesDeploy.php
diff options
context:
space:
mode:
authorRob Loach <robloach@gmail.com>2013-12-14 16:41:10 -0500
committerRob Loach <robloach@gmail.com>2013-12-14 16:41:10 -0500
commit2596307917045df71d8922d7bc46bad00f5ec694 (patch)
tree05ba8d84756332a1eecfe0896472cd5e43f7ca5c /src/GitHubPagesDeploy/GitHubPagesDeploy.php
parentd0fc289e7839727ea42abfa6244713a4a94991dc (diff)
downloadgit-deploy-2596307917045df71d8922d7bc46bad00f5ec694.zip
git-deploy-2596307917045df71d8922d7bc46bad00f5ec694.tar.gz
git-deploy-2596307917045df71d8922d7bc46bad00f5ec694.tar.bz2
Initial commit
Diffstat (limited to 'src/GitHubPagesDeploy/GitHubPagesDeploy.php')
-rw-r--r--src/GitHubPagesDeploy/GitHubPagesDeploy.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/GitHubPagesDeploy/GitHubPagesDeploy.php b/src/GitHubPagesDeploy/GitHubPagesDeploy.php
new file mode 100644
index 0000000..c7f1a17
--- /dev/null
+++ b/src/GitHubPagesDeploy/GitHubPagesDeploy.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace GitHubPagesDeploy;
+
+use GitWrapper\GitWrapper;
+use GitWrapper\GitWorkingCopy;
+
+class GitHubPagesDeploy
+{
+ protected $repositories;
+
+ public function __construct($repositories = array())
+ {
+ $this->repositories = $repositories;
+ }
+
+ public static function fromFile($file = 'gh-pages-deploy.json')
+ {
+ $results = array();
+
+ if (is_file($file)) {
+ $contents = file_get_contents($file);
+ $results = json_decode($contents);
+ }
+
+ return new GitHubPagesDeploy($results);
+ }
+
+ public function update()
+ {
+ // Create the wrapper.
+ $wrapper = new GitWrapper();
+ $wrapper->streamOutput();
+
+ foreach ($this->repositories as $dir => $repo) {
+ $git = null;
+ if (!is_dir($dir)) {
+ $git = $wrapper->cloneRepository($repo, $dir);
+ }
+ else {
+ $git = new GitWorkingCopy($wrapper, $dir);
+ }
+
+ $git->checkout('gh-pages');
+ $git->pull();
+ }
+ }
+
+ public function getRepositories()
+ {
+ return $this->repositories;
+ }
+}