View Categories

Revisions

Every snippet keeps a history of its earlier versions. You can compare any revision with the current snippet and restore it.

When a revision is saved #

A revision is recorded whenever a snippet’s content changes:

  • you save the snippet
  • a GitHub update is applied, by hand or automatically
  • a new snippet arrives from a GitHub collection
  • a snippet is imported
  • a revision is restored

If nothing changed since the last revision, no new one is recorded. Activating or deactivating a snippet, moving it to a folder, and changing its tags do not create revisions.

What a revision contains #

  • the source code
  • the name and description
  • the type
  • the scope settings
  • the config values
  • for GitHub snippets, the version, hash and changelog link

Comparing and restoring #

The Revisions card on the snippet edit screen lists the revisions, newest first. Each shows what produced it, the version (for GitHub snippets), when it was recorded and who made the change. The newest revision is the snippet as it is now and is marked Current.

Click Compare & restore on any older revision to see:

  • a line-by-line diff of the source code, from the current code to the revision
  • the config values that would change
  • any other changes the restore makes (name, description, type, version, scope or requirements)

Click Restore This Revision to bring that version back. The restore is recorded as a new revision, so you can undo it the same way.

Restoring does not change:

  • whether the snippet is active
  • its folder or tags
  • any update that is waiting for review

If the snippet is active, its file is rebuilt from the restored code before anything is saved. If that fails, for example because of a syntax error, nothing is changed and the error is shown.

Save or discard your edits before restoring. Unsaved changes in the editor are lost when the page reloads.

Config values #

Config values are restored for every variable that the restored code declares. A variable the restored code no longer declares keeps its value as an orphaned config, just as it does after an update that removes a variable.

GitHub snippets #

You can restore an earlier version of a GitHub snippet, for example to roll back an update that caused problems. The next sync then sees that the snippet differs from the collection:

  • Auto-update off: the newer version is offered as an update for review.
  • Auto-update on: the newer version may be applied again automatically.

How many revisions are kept #

Each snippet keeps its 50 most recent revisions, and older ones are deleted. Deleting a snippet deletes its revisions.

Developers can change the limit with the gocsm_revisions_to_keep filter:

add_filter( 'gocsm_revisions_to_keep', fn() => 20 );

After a restore, the gocsm_revision_restored action fires with the snippet ID and the restored revision.