aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-29 10:18:26 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-29 10:18:26 -0400
commit63a97ff6fc313372d9cb439a621f12fdecc2fac1 (patch)
treeb77b9e3133def566a34530727a64d3915b2d2aec /Zotlabs
parentab54bf514921ae3fe0fafcdf154364815ed6375f (diff)
downloadvolse-hubzilla-63a97ff6fc313372d9cb439a621f12fdecc2fac1.tar.gz
volse-hubzilla-63a97ff6fc313372d9cb439a621f12fdecc2fac1.tar.bz2
volse-hubzilla-63a97ff6fc313372d9cb439a621f12fdecc2fac1.zip
Git commit made for the page edits when the page is saved.
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Wiki.php15
-rw-r--r--Zotlabs/Storage/GitRepo.php9
2 files changed, 22 insertions, 2 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 5d293e6f0..70d326faf 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -268,9 +268,20 @@ class Wiki extends \Zotlabs\Web\Controller {
}
$saved = wiki_save_page(array('resource_id' => $resource_id, 'name' => $pagename, 'content' => $content));
if($saved['success']) {
- json_return_and_die(array('success' => true));
+ $ob = \App::get_observer();
+ $commit = wiki_git_commit(array(
+ 'commit_msg' => 'Updated ' . $pagename,
+ 'resource_id' => $resource_id,
+ 'observer' => $ob,
+ 'files' => array($pagename)
+ ));
+ if($commit['success']) {
+ json_return_and_die(array('message' => 'Wiki git repo commit made', 'success' => true));
+ } else {
+ json_return_and_die(array('message' => 'Error making git commit','success' => false));
+ }
} else {
- json_return_and_die(array('success' => false));
+ json_return_and_die(array('message' => 'Error saving page', 'success' => false));
}
}
diff --git a/Zotlabs/Storage/GitRepo.php b/Zotlabs/Storage/GitRepo.php
index f4a129bb3..306abc0ba 100644
--- a/Zotlabs/Storage/GitRepo.php
+++ b/Zotlabs/Storage/GitRepo.php
@@ -127,6 +127,15 @@ class GitRepo {
$repo['logs'] = $git->log(array('limit' => 50));
return $repo;
}
+
+ // Commit changes to the repo. Default is to stage all changes and commit everything.
+ public function commit($msg, $options = array()) {
+ try {
+ return $this->git->commit($msg, $options);
+ } catch (\PHPGit\Exception\GitException $ex) {
+ return false;
+ }
+ }
public static function isValidGitRepoURL($url) {
if (validate_url($url) && strrpos(parse_url($url, PHP_URL_PATH), '.')) {