Coder Social home page Coder Social logo

spock's Introduction

Spock for Statamic Statamic 2.10

Perform commands when content has been published or changed.

This addon essentially just listens for an event, and dispatches commands. Who better to listen and command than a Starship Commander with large ears?

Its primary use is to automatically commit and push changes in production, but it can do anything your command line can.

Documentation

Read it on the Statamic Marketplace or contribute to it here on GitHub.

Requirements

Statamic 2.10 is required. If you intend to run Spock on an earlier version of Statamic, please checkout Spock's v1 branch.

Developing

You can use Kessel Run to copy files to your Statamic installation, and run php please test:addons to run Spock's tests.

spock's People

Contributors

alwaysblank avatar jackmcdade avatar jasonvarga avatar jesseleite avatar sagalbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spock's Issues

Lots of issues - Not pushing most of the times

I'm trying to get Spock to work all day today, but no luck. It just doesn't really push most of the time and throws lots of errors in the log file.

Basically it doesn't even push new collection entries, it logs errors about index.lock files that it thinks exist, but that aren't there when I check the /.git/ dir.

I am ignoring Asset events, as all assets are on S3, and before Spock was also throwing errors about not finding the asset files, this is my spock.yaml:

environments:
  - production
git_push: true
git_username: Spock
git_email: [email protected]
ignore_events:
  - Statamic\Events\Data\AssetUploaded
  - Statamic\Events\Data\AssetMoved
  - Statamic\Events\Data\AssetDeleted
  - Statamic\Events\Data\AssetFolderSaved
  - Statamic\Events\Data\AssetFolderDeleted

There were some successful pushes, but it's unreliable at best, for a while now I wasn't able to get it to push anything, always logs like the ones below.

These logs are from adding a single new entry:


LEVEL	CONTEXT	DATE	CONTENT
 error	production	2019-02-23 15:19:20	Spock command exited unsuccessfully:
Command: git -c "user.name=Spock" -c "[email protected]" commit -m "Term saved by madsem"
Output: 
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
	site/content/collections/reviews/2019-02-23.tonalenergy-tuner-and-metronome.md
	site/content/taxonomies/apps/music-audio.yaml
	site/storage/addons/AppStoreApi/com.sonosaurus.tonalenergytuner.json


It took 2.03 seconds to enumerate untracked files. 'status -uno'
may speed it up, but you have to be careful not to forget to add
new files yourself (see 'git help status').
nothing added to commit but untracked files present

Error: No error
 error	production	2019-02-23 15:19:20	Spock command exited unsuccessfully:
Command: git -c "user.name=Spock" -c "[email protected]" commit -m "Entry saved by madsem"
Output: 
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
	site/content/collections/reviews/2019-02-23.tonalenergy-tuner-and-metronome.md
	site/content/taxonomies/apps/music-audio.yaml
	site/storage/addons/AppStoreApi/com.sonosaurus.tonalenergytuner.json

nothing added to commit but untracked files present

Error: No error
 error	production	2019-02-23 15:19:18	Spock command exited unsuccessfully:
Command: git -c "user.name=Spock" -c "[email protected]" commit -m "Taxonomy saved by madsem"
Output: No output
Error: 
fatal: Unable to create '/home/forge/somewebsite.online/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
 error	production	2019-02-23 15:19:17	Spock command exited unsuccessfully:
Command: git add /home/forge/somewebsite.online/site/content/collections/reviews/tonalenergy-tuner-and-metronome.md
Output: No output
Error: 
fatal: Unable to create '/home/forge/somewebsite.online/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
 error	production	2019-02-23 15:19:17	Spock command exited unsuccessfully:
Command: git add /home/forge/somewebsite.online/site/content/collections/reviews/2019-02-23.tonalenergy-tuner-and-metronome.md
Output: No output
Error: 
fatal: Unable to create '/home/forge/somewebsite.online/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
 error	production	2019-02-23 15:19:16	Spock command exited unsuccessfully:
Command: git add /home/forge/somewebsite.online/site/content/taxonomies/apps/music-audio.yaml
Output: No output
Error: 
fatal: Unable to create '/home/forge/somewebsite.online/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

Server: Ubuntu 18 / Nginx (Default Laravel Forge Setup)
Latest Statamic: 2.11.9
Spock 2.2.1
Repo Type: Private

Spock doesn't git push

I followed all the issues and forum posts on The Lodge. I'm running the Spock with the latest Pull request provided by rrelmy. Spock is commiting the changes but it doesn't push them. I have to manually git push. Any lead on this issue? I would really love to have a working Spock instance!

I'm running the latest Statamic 2.8.2.

My config

environments:
  - production
  - prod
commands:
  - "git add {{ full_path }}"
  - "git commit -m '{{ url }} updated by {{ committer:username }}'"
  - "git push"

Spock does not commit image presets

Spock has been working great but I noticed when an image is created with a front end form like Workshop, the image presets do not auto-commit with Spock. This could also be happening in the CP as well, but I have not tested that. For example, I uploaded an image on a Workshop form and this what is committed:

 2 files changed, 7 insertions(+)
 create mode 100755 public_html/assets/images/events/test.jpg
 create mode 100755 site/content/collections/events/2018-08-14.test-event.md

but when I try a git pull to local I get this error:

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        public_html/img/containers/main/images/events/test.jpg/

nothing added to commit but untracked files present (use "git add" to track)

You can see the issue.

This is my assets.yaml

image_manipulation_route: /img
image_manipulation_secure: true
auto_crop: true
image_manipulation_driver: gd
image_manipulation_cached: true
image_manipulation_cached_path: public_html/img
image_manipulation_presets:
  header:
    w: 1920
    h: 1080
  body:
    w: 1200
    h: 500
  cards:
    w: 800
    h: 500
  seo:
    w: 1200
    h: 630
  logo:
    w: 375
  modal:
    w: 1500
thumbnail_max_width: 6000
thumbnail_max_height: 6000

Can Spock also fire when forms are submitted?

I finally got Spock setup but it does not fire on form submissions. So when I git pull/push from local I always get the warning about the form yaml files and the MERGE junk if a form was submitted after the last content was saved. Any way to make Spock fire on form submissions as well?

Errors when running tests.

Statamic 2.11.16, PHP 7.4.

4) Statamic\Addons\Spock\CommanderTest::only_runs_commands_for_whitelisted_environments
ErrorException: Cannot use "parent" when current class scope has no parent

/Users/erin/Sites/simple/statamic/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php:16
/Users/erin/Sites/simple/statamic/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php:16
/Users/erin/Sites/simple/statamic/vendor/mockery/mockery/library/Mockery/Container.php:219
/Users/erin/Sites/simple/statamic/vendor/mockery/mockery/library/Mockery.php:98
/Users/erin/Sites/simple/site/addons/Spock/tests/CommanderTest.php:16

Missing possibility to have a custom Git commit command

Just updated to Spock 2.0.1, but I'm missing the possibility to have a custom commit command, like I had in Spock 1:

commands:
  - "git add {{ full_path }}"
  - "git -c user.name='{{ committer:first_name }} {{ committer:last_name }}' -c user.email='{{ committer:username }}' commit -m 'Update {{ url }}'"

Spock + Laravel Forge

Hi! I have a setup with Statamic, Spock and Laravel Forge and quite often get the following failure when quick deploy runs:

error: cannot lock ref 'refs/remotes/origin/master': is at <last commit hash> but expected <previous commit hash>
From gitlab.com:organizayion/reposotory
! <previous commit short hash>..<last commit short hash> master -> origin/master (unable to update local ref)

I have the following deployment script:

git fetch

LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})

[ $LOCAL = $REMOTE ] && exit 0

git pull origin master
# composer update, php-fpm restart, etc

After getting this deployment failure notification and checking the server the repository is at the latest commit and there are no other problems.
I would really appreciate if someone could help me out finding where the problem is and how can I address it. Thanks!

Unable to save spock config

I'm getting the following error when I try to save my spock config:

[2018-09-11 07:39:48] staging.ERROR: exception 'ErrorException' with message 'Argument 1 passed to Statamic\Events\Data\AddonSettingsSaved::__construct() must be an instance of Statamic\Events\Data\string, string given, called in /var/www/statamic/statamic/core/Http/Controllers/AddonsController.php on line 144 and defined' in /var/www/statamic/statamic/core/Events/Data/AddonSettingsSaved.php:24 Stack trace: #0 /var/www/statamic/statamic/core/Events/Data/AddonSettingsSaved.php(24): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(4096, 'Argument 1 pass...', '/var/www/statam...', 24, Array) #1 /var/www/statamic/statamic/core/Http/Controllers/AddonsController.php(144): Statamic\Events\Data\AddonSettingsSaved->__construct('/var/www/statam...', Array) #2 [internal function]: Statamic\Http\Controllers\AddonsController->saveSettings(Object(Illuminate\Http\Request), 'Spock') #3 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array(Array, Array) #4 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction('saveSettings', Array) #5 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): Illuminate\Routing\ControllerDispatcher->call(Object(Statamic\Http\Controllers\AddonsController), Object(Illuminate\Routing\Route), 'saveSettings') #6 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #7 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #8 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #9 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #10 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #11 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(69): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(Statamic\Http\Controllers\AddonsController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'saveSettings') #12 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'Statamic\Http\C...', 'saveSettings') #13 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request)) #14 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request)) #15 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #16 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #17 /var/www/statamic/statamic/core/Http/Middleware/CP/Configurable.php(23): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #18 [internal function]: Statamic\Http\Middleware\CP\Configurable->handle(Object(Illuminate\Http\Request), Object(Closure)) #19 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #20 /var/www/statamic/statamic/core/Http/Middleware/CP/Authenticate.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #21 [internal function]: Statamic\Http\Middleware\CP\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure)) #22 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #23 /var/www/statamic/statamic/core/Http/Middleware/Outpost.php(48): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #24 [internal function]: Statamic\Http\Middleware\Outpost->handle(Object(Illuminate\Http\Request), Object(Closure)) #25 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #26 /var/www/statamic/statamic/core/Http/Middleware/CP/Localize.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #27 [internal function]: Statamic\Http\Middleware\CP\Localize->handle(Object(Illuminate\Http\Request), Object(Closure)) #28 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #29 /var/www/statamic/statamic/core/Http/Middleware/CP/DefaultLocale.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #30 [internal function]: Statamic\Http\Middleware\CP\DefaultLocale->handle(Object(Illuminate\Http\Request), Object(Closure)) #31 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #32 /var/www/statamic/statamic/core/Http/Middleware/CpEnabled.php(23): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #33 [internal function]: Statamic\Http\Middleware\CpEnabled->handle(Object(Illuminate\Http\Request), Object(Closure)) #34 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #35 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #36 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #37 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #38 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) #39 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #40 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #41 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request)) #42 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #43 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #44 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure)) #45 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #46 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #47 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #48 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #49 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #50 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #51 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #52 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #53 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure)) #54 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #55 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #56 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure)) #57 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #58 /var/www/statamic/statamic/core/StaticCaching/Middleware/Retrieve.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #59 [internal function]: Statamic\StaticCaching\Middleware\Retrieve->handle(Object(Illuminate\Http\Request), Object(Closure)) #60 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #61 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #62 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #63 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #64 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #65 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #66 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #67 /var/www/statamic/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #68 /var/www/statamic/public/com/index.php(156): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #69 {main}

Statamic version: 2.10.2
Spock version: 2.0.1

Any help would be much appreciated. Thanks.

Spock doesn't 'Git Add' localized content

When creating or updating localized content, Spock doesn't run Git Add. (Git status does display the changes).

Other content, fieldset-updates, etc. are added, committed and pushed as they should.

Using Statamic v2.11.3
Spock v2.1.0

Primary locale is set to 'NL'. Secondary locale is 'EN'.

Spock hangs up Statamic on content save/reorder for... a while

Was having an issue with re-ordering entries within a collection taking a long time (18s+) to complete, as well as intermittent long waits to save content, fieldset configs, etc. โ€” eventually determined (with help from Erin over on the Statamic Discord channel) that Spock was the culprit. Removing Spock from my addons returned save/reorder performance to nigh-immediate execution.

Erin's suspicion was that something's maybe not getting queued properly? Bug perhaps?

Spock doesn't track unpublished collection entry

When unpublishing a collection entry, Spock adds, commits and pushes the unpublished file with the underscore e.g. _entry.md as expected. But it doesn't track the deleted file entry.md. I had to add, commit and push it myself. Great, if this can be fixed.

Spock missing some events?

I was looking at SpockListener.php and it seems like it is missing some files from the \Statamic\Events\Data\ folder.

For example, Spock has PageSaved, PageDeleted, and PagesMoved, but is missing stuff like PagesReordered, PageMoved.

Is it safe to just add everything from \Statamic\Events\Data\ into the public $events array in SpockListener.php? Or is there reasons some of those events are not included? Are they maybe bugged on some of them?

Statamic V3

Do you all have plans for getting Spock to work with Statamic V3?

Errors firing when there is no Error from git

There seems to be an issue with the git command exiting unsuccessfully, but the error returned suggests that there is no issues with the command. Here is an example:

ERROR
Spock command exited unsuccessfully:
Command: git -c "user.name=statamic" -c "user.email=REDACTED" commit -m "Page saved by Admin"
Output:
On branch cms
Your branch is up to date with 'origin/cms'.
nothing to commit, working tree clean
Error: No error

Is this something that can be filtered out? I can't imagine a point where "Error: No error" actually means the opposite ๐Ÿ˜‚.

Spock asking for Git Config Credentials even though Set Already in .gitconfig

Upon install, when tested Spock gives this error in logs:

[2018-04-26 06:45:55] production.ERROR: Spock command exited unsuccessfully: 
git add --all; git commit -m '/aging-friendly-communities/growing-need updated by bgarrant'

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <[email protected]>) not allowed

I already have a .gitconfig in the root with these settings:

[user]
	email = [email protected]
	name = Bryan Garrant

So where is it saving these new credentials? It is not in the root so must be elsewhere? I have Statamic installed above my webroot so maybe that is why? Regardless if I run those commands without the --global tag it fixes the issue:

Run

  git config user.email "[email protected]"
  git config user.name "Your Name"

Spock + gpg

๐Ÿ‘‹ Hello! I'm wondering if anyone has successfully gotten Spock working with GPG or knows of any workarounds besides disabling commit signing. Right now, commits don't work and I keep getting this error:

[2019-06-18 19:03:23] production.ERROR: Spock command exited unsuccessfully:
Command: git commit -m "Addon settings saved by admin"
Output: No output
Error: 
error: cannot run gpg: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object  

Not a huge deal since I'm just on my local machine, but again, just putting this out there in case anyone has any insight.

Maybe it's worth adding the ability to specify some more Git configs within Spock's settings? What if you could arbitrarily add any config you wanted, and Spock would just add git -c key=value (in this case, git -c commit.gpgsign=false) to each commit? Is there anything inherently terrible in that approach?

git_username in config not working

Transferred a Forge server to a client's ownership and they were asking about removing me from the commit logs.

Tried adding

git_username: "Webby McWebFace"
git_email: "[email protected]"

to spock.yaml settings but didn't have any affect. Had to manually go into the server and do git config --global user.name "Webby McWebFace"

This might not even be a Spock issue but wondered if you'd ran into it before?

Issue with localization

Is there something I can do to make spock work for localized content ? Spock seems to try and add files from the non-localized paths

From the logs:

[2018-09-13 07:37:18] staging.ERROR: Spock command exited unsuccessfully:
Command: git add /var/www/statamic/site/content/collections/learn/jay-chin-testing-page.md
Output: No output
Error: 
fatal: pathspec '/var/www/statamic/site/content/collections/learn/jay-chin-testing-page.md' did not match any files

Files that were actually modified:

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	collections/learn/au/_jay-chin-testing-page.md
	collections/learn/ce/_jay-chin-testing-page.md
	collections/learn/cf/_jay-chin-testing-page.md
	collections/learn/de/_jay-chin-testing-page.md
	collections/learn/es/_jay-chin-testing-page.md
	collections/learn/gb/_jay-chin-testing-page.md
	collections/learn/gl/_jay-chin-testing-page.md
	collections/learn/it/_jay-chin-testing-page.md
	collections/learn/jp/_jay-chin-testing-page.md
	collections/learn/mx/_jay-chin-testing-page.md
	collections/learn/nl/_jay-chin-testing-page.md

Asset Changes not detected by Spock

I can confirm the issue reported by Waze:

Spock is not getting notified about asset changes and is therefore not able to commit them. We also added an manual workaround similary to @wanze.

However, sSince this is throwing errors on every failed commit it would be great if this could be fixed. We are using Statamic 2.11.5and Spock 2.1.0.

Originally posted by @wanze in #24 (comment) :

I am also running into this issue using the following setup:

  • Statamic 2.11.3
  • Spock 2.1.0

Ignored events:

  - Statamic\Events\Data\AssetUploaded
  - Statamic\Events\Data\AssetMoved
  - Statamic\Events\Data\AssetDeleted
  - Statamic\Events\Data\FileUploaded

My current solution is to use a custom after command:

- if (( $(git status -s | wc -l) > 0 )); then git add --all && git commit -m "[skip-ci] Additional changes after running Spock" && git push; fi

Re-ordering entries causes multiple commits

Re-ordering entries causes multiple commits (one per entry), in contrast to re-ordering pages which fires a single PagesMoved event (and therefore a single commit).

This actually needs to be addressed in the Statamic core with a new EntriesMoved event that overrides the individual EntrySaved events, but since it's being reported in unrelated issues here (see #32 (comment) and #31 (comment)), I thought I'd create a new issue to address this specifically ๐Ÿ™‚

Using Spock for auto commit to git repo

My intention for using the spock addon was for the purpose of using Git to automatically commit and push any changes up to a repo for change management purposes, and in trying to set this up I found a few things I had to adjust to make it work the way I wanted, and thought I'd let anyone else know in the event anyone else is wanting to use it for the same purpose.

I found that the git add {{ full_path }} command didn't work correctly, so I switched to trying to use git add . and found that while that added new files and updated existing ones, it did not remove any of the deleted files. I found that I could use git add --all in order to also catch any deleted files.

After finding something that would catch deleted files for the git command when the events fired I quickly found while testing that the event wasn't getting triggered when pages were deleted, which I felt was worth trying to catch. I found that I could add PageDeleted::class => 'run' to the $events array in SpockListener.php but that it had a few issues with the code later in the commands() function that referenced properties on $this->data passed in from the event. Since I wasn't using any of the properties on $this->data I just went ahead and commented those lines out and was able to get it to catch deletions and commit them whenever they happened also.

SpockListener.php

    /**
     * Spock has no trouble listening for these events with those ears.
     *
     * @var array
     */
    public $events = [
        'cp.published' => 'run',
        PageDeleted::class => 'run'
    ];
    /**
     * Get the concat'ed commands
     *
     * @return string
     */
    private function commands()
    {
        #$full_path = Path::assemble(root_path(), $this->data->path());

        #$data = $this->data->toArray();
        #$data['full_path'] = $full_path;
        $data['committer'] = User::getCurrent()->toArray();

        $commands = [];

        foreach ($this->getConfig('commands', []) as $command) {
            $commands[] = Parse::template($command, $data);
        }

        return join('; ', $commands);
    }

spock.yml

environments:
  - production
commands:
  - "git add --all"
  - "git commit -m '{{ url }} updated by {{ committer:username }}'"
  - "git push"

I'd be curious to know if anyone else has come up with any better way of managing changes in the control panel to automatically get put back into a git repo for change management purposes.

We'd like to be able to use this so we have one site as a staging/development site to prepare content and changes, test it, get it approved, and then be able to issue pull requests to take a specific commit or branch (develop) over into production (master) on a separate environment.

Custom commit message

So I know you can create custom commands to do things, but is there an easy way to add some text before/after the commit message so that when looking at the commit history we know it's from Spock?

So instead of Submission saved it could be [Spock] Submission saved or some other easy way to see what's an automated change versus a human one?

Make spock show up in the Addons list

Hey guys,

I'm just trying to setup Spock, but it doesn't seem to be appearing in my list of add-ons in the control panel so I guess I'm doing something wrong.

Fold structure looks like so:

image

Any ideas where I'm going wrong?

Thanks!

Spock logs errors if entires are sorted by date

Hey!
I have collection in statamic which is sorted by date so they are prefixed with date string. When spock is checking the affectedPaths() while adding to git, it also finds the path without the date string prefix, which does not exist anymore and therefore spock logs following error:

Command: git add '.../site/content/collections/blog-posts/foobar.md' Output: No output Error: fatal: pathspec '.../site/content/collections/blog-posts/foobar.md' did not match any files

but it also correctly adds the file which is called 2019-10-03.foobar.md to git, but it's just problematic to have false positives while handling errors.

Unit tests are broken

php please test
PHPUnit 5.7.20 by Sebastian Bergmann and contributors.

.............EE..EEEEE.........                                   31 / 31 (100%)

Time: 2.62 seconds, Memory: 30.00MB

There were 7 errors:

1) Statamic\Addons\Spock\CommanderTest::only_runs_commands_for_whitelisted_environments
ErrorException: get_class() expects parameter 1 to be object, null given

/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:115
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:105
/Users/remy/projects/web/statamic_standard/site/addons/Spock/tests/CommanderTest.php:31

2) Statamic\Addons\Spock\CommanderTest::does_not_run_command_if_event_is_ignored
ErrorException: get_class() expects parameter 1 to be object, null given

/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:115
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:105
/Users/remy/projects/web/statamic_standard/site/addons/Spock/tests/CommanderTest.php:48

3) Statamic\Addons\Spock\CommanderTest::commands_are_run
ErrorException: get_class() expects parameter 1 to be object, null given

/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:115
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:105
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:33
/Users/remy/projects/web/statamic_standard/site/addons/Spock/tests/CommanderTest.php:85

4) Statamic\Addons\Spock\CommanderTest::erroring_commands_are_logged
ErrorException: get_class() expects parameter 1 to be object, null given

/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:115
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:105
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:33
/Users/remy/projects/web/statamic_standard/site/addons/Spock/tests/CommanderTest.php:97

5) Statamic\Addons\Spock\CommanderTest::failed_commands_are_logged
ErrorException: get_class() expects parameter 1 to be object, null given

/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:115
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:105
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:33
/Users/remy/projects/web/statamic_standard/site/addons/Spock/tests/CommanderTest.php:113

6) Statamic\Addons\Spock\CommanderTest::the_literal_string_no_output_is_shown_if_theres_no_output
ErrorException: get_class() expects parameter 1 to be object, null given

/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:115
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:105
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:33
/Users/remy/projects/web/statamic_standard/site/addons/Spock/tests/CommanderTest.php:132

7) Statamic\Addons\Spock\CommanderTest::the_literal_string_no_error_is_shown_if_theres_no_error
ErrorException: get_class() expects parameter 1 to be object, null given

/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:115
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:105
/Users/remy/projects/web/statamic_standard/site/addons/Spock/Commander.php:33
/Users/remy/projects/web/statamic_standard/site/addons/Spock/tests/CommanderTest.php:151

Can someone confirm this?

Spock does not commit changes to assets yaml file

Adding a new post and uploading an asset with addition metadata causes Spock to commit the post but not the metadata changes in the asset container .yaml file.

Spoke with Jason on Discord and he confirmed "spock isn't listening for when assets are saved"

LOG.error: Spock command exited unsuccessfully

[09:48:21] LOG.error: Spock command exited unsuccessfully:
Command: git -c "user.name=######" -c "user.email=######" commit -m "Addon settings saved by ######"
Output: 
# On branch develop
# Your branch is ahead of 'origin/develop' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   .htaccess
#	modified:   site/content/collections/articles/2020-04-02.mollis-justo-malesuada-dolor.md
#	modified:   site/settings/addons/seo_pro.yaml
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	site/settings/addons/big_kahuna.yaml
no changes added to commit (use "git add" and/or "git commit -a")

Error: No error
[09:48:22] LOG.error: Spock command exited unsuccessfully:
Command: git push
Output: No output
Error: 
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

fatal: could not read Username for 'https://github.com': No such device or address

Git Config file

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://github.com/#####/##########.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "develop"]
	remote = origin
	merge = refs/heads/develop
[user]
	email = ############
	name = #############

I'm receiving the above errors with Spock. Here is what I have tried.

I started again using https://github.com/username/folder.git instead of the ssh method as I found a load of articles around permission denied. However I get the same error as above.

Now getting fatal: could not read Username for https://github.com: No such device or address even though its been set through git config and inputted into control panel

####indicates correct details are inputted

Commands don't appear to run on Publish

Hey guys.
I feel like I must be missing something. I haven't had any luck running Spock on my production or dev environments. Are there dependencies that Spock requires to run?

I've installed the Spock addon, configured the Spock settings and .env file.

/site/settings/addons/spock.yaml

environments:
  - dev
commands:
  - "git add {{ full_path }}"
  - "git commit -m '{{ url }} updated by {{ committer:username }}'"

.env

APP_ENV=dev

Update:
There appears to be an issue with {{ full_path }} and local user permissions.
See Lodge post here.

Working with Spock v2

I noticed there was a v2 branch being worked on by @jasonvarga, so I pulled down the latest commit at 89ddda6 but can't seem to get it to run. Tests are passing, but I can't seem to get it to actually commit on save.

Has there been a change in the setup steps?

I've tried without a spock.yaml in settings/addons and also with the file there (as was previously in the current release version).

Can't seem to get it to work either way.

I'm very interested in working with the functionality that has been added from the commit logs and would happily contribute if required, as we will be working with Statamic for the foreseeable future and a fully featured spock would be excellent.

Class 'Statamic\Addons\addons\Spock\SpockServiceProvider' not found

I'm trying to implement this add-on but I can not make it work, I just paste the addon folder and I get the following error:

FatalThrowableError in Application.php line 575:
Class 'Statamic \ Addons \ addons \ Spock \ SpockServiceProvider' not found

I have already added the lines indicated in the AddonServiceProvider.php file and added the spock.yaml file but it still does not work. I hope you can help me install and run this add-on. Thank you for the attention.

Spock can't handle ssh keys

Hee Guys,

We are new to spock and are having trouble with using spock to push to our git (bitbucket) repository. It is a private repository and needs an ssh key (or user and password) but how are we going to let spock use an ssh key and password?

Please let me know.

Special characters in filenames

Hi,

Some special characters in filenames are preventing spock from adding files.

Error: No error  
[2019-04-11 09:18:22] production.ERROR: Spock command exited unsuccessfully:
Command: git add /var/www/vhosts/domain.at/httpdocs/domain.at/statamic/../assets/images/1-bike-(1)marz-4.jpg
Output: No output
Error: 
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `git add /var/www/vhosts/domain.at/httpdocs/domain.at/statamic/../assets/images/bike-(1)marz-4.jpg'  
[2019-04-11 09:18:22] production.ERROR: Spock command exited unsuccessfully:
Command: git commit -m "Asset uploaded by admin"
Output: 
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	assets/images/bike-(1)marz-4.jpg
nothing added to commit but untracked files present (use "git add" to track)

Is the remote version should be a git repo?

I know this is a silly question. But does my remote target should be a git repo as well?
I mean, should i git clone my project on the remote server first before using Spock?

My staging and production site is not managed via Git. It's deployed using rsync via Jenkins.

spock doesn't commit on localhost

Have statamic set up in MAMP Pro localhost root folder, with git repo.

Manual changes in control panel don't trigger any commits from spock, even though the git repo shows files are modified.

The documentation says "out of the box", do I need to do additional config for localhost?

thanks
J

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.