Skip to content

Commit

Permalink
Merge branch 'refactoring'
Browse files Browse the repository at this point in the history
# Conflicts:
#	helpers.php
#	readme.md
  • Loading branch information
pascalmh committed Sep 21, 2015
2 parents 90204c5 + 622b43f commit 6af8e57
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 36 deletions.
24 changes: 12 additions & 12 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
* @return false
*/
function gitCommit($commitMessage) {
$branch = c::get('gcapc-branch') || 'master';
$pull = c::get('gcapc-pull') || true;
$push = c::get('gcapc-push') || true;
$commit = c::get('gcapc-commit') || true;
$pushCommand = c::get('gcapc-pushCommand') || 'git push';

exec(
'cd ../content/ && ' .
'git add -A &&' .
'git commit -m "' . $commitMessage . ' by ' . site()->user() . '"' .
(
server::get('SERVER_ADDR') != "localhost"
? ' && git push "ext::ssh -i ' .
c::get('gcapcSshKeyPath') . ' ' .
c::get('gcapcGitServer') . ' %S ' .
c::get('gcapcGitRepository') . '"'
: ''
),
$output
'cd ../content/' .
' && git checkout -b ' . $branch . '' .
$pull ? ' && git pull' : '' .
$commit ? ' && git add -A' : '' .
$commit ? ' && git commit -m "' . $commitMessage . ' by ' . site()->user() . '"' : '' .
$push ? ' && ' . $pushCommand : ''
);

return false;
Expand Down
68 changes: 44 additions & 24 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,26 @@

This is a plugin for [Kirby](http://getkirby.com/) that Commits and Pushes Changes made via the Panel to your Git Repository.

## Usage

Just keep using the Panel as you are used to and watch the commits appear in your git repository!

## Installation

### Create a new git repository for your content

Create a new git repository where you push your content to, name it `your-project_content`.

### Download and configure the Plugin

Put all the files into your `site/plugins/git-commit-and-push-content/` folder. If the `git-commit-and-push-content/` plugin folder doesn't exist then create it.

Or: go into you `site/plugins/` folder and `git clone https://github.com/Pascalmh/kirby-git-commit-and-push-content git-commit-and-push-content`.
Init the content repo and push it

Add this to your `site/config/config.php` and adapt it to your needs:
```php
// Plugin: git-commit-push-content
c::set('gcapcSshKeyPath', '.ssh/id_rsa'); // .ssh/id_rsa
c::set('gcapcGitServer', '[email protected]'); // [email protected]
c::set('gcapcGitRepository', 'your-project/your-project_content.git'); // your-project/your-project_content.git
```

`gcapcSshKeyPath` - Create a new Git User with Push Permissions, generate an ssh-key for it and put it on the server
`gcapcGitServer` - Hostname with optional user, for example `[email protected]`
`gcapcGitRepository` - your git repository `your-project/your-project_content.git`

### Init the content repo and push it

Remove `content/` folder from your current git repository
Remove the `content/` folder from your current git repository
```
git rm --cached -r content
git add -A
git commit -m "Move Content Folder to separate repository"
```

Add `content/` folder to new git repository
Add the `content/` folder to new git repository

```
cd content
Expand All @@ -46,11 +32,45 @@ git commit -m "Initial Content Commit"
git push origin master
```

## Usage
### Download and configure the Plugin

Go into your `site/plugins/` folder and `git clone https://github.com/Pascalmh/kirby-git-commit-and-push-content git-commit-and-push-content`.

Or: Put all the files into your `site/plugins/git-commit-and-push-content/` folder. If the `git-commit-and-push-content/` plugin folder doesn't exist then create it.

### Options

You can use the following [Options](http://getkirby.com/docs/advanced/options) - make use of kirbys [Multi-environment setup](http://getkirby.com/blog/multi-environment-setup).

#### gcapc-branch
Type: `String`
Default value: `master`

branch name to be checked out

#### gcapc-pull
Type: `Boolean`
Default value: `true`

Pull remote changes first?

#### gcapc-commit
Type: `Boolean`
Default value: `true`

Commit your changes?

#### gcapc-push
Type: `Boolean`
Default value: `true`

Push your changes to remote?

Just keep using the Panel as you are used to and watch the commits appear in you git repository!
#### gcapc-pushCommand
Type: `String`
Default value: `git push`

If you are on localhost you need to push your changes manually.
[git push](http://git-scm.com/docs/git-push)

## Author

Expand Down

0 comments on commit 6af8e57

Please sign in to comment.