Skip to content

#LiveCode tool to track changes to scripts of a stack

Notifications You must be signed in to change notification settings

bwmilby/scriptTracker

Repository files navigation

Script Tracker

The goal of this tool is to expose the scripts of a binary stack in a fashion that allows them to be tracked via a version control system like GitHub. This repo contains the output of the stack. Even though GitHub can't provide useful information about the changes in binary files, each time I perform a commit I include the corresponding binary stack. This allows easy download of the stack for use but also puts the scripts in a convenient place for review online.

Each script in the stack is exported as a valid .livecodescript file, but the stack is not modified to make it a behavior. A custom property set is created for each object to track a hash of the script and the modification date/time of the exported file. On each sync, those properties are used to determine if the script needs to be exported or if the file needs to be imported. Whenever a script changes, a diff file is created that contains all of the changes in that particular sync operation. If a file is no longer needed (i.e. the script was removed), then the extra files are moved to a separate directory and renamed to ensure no name collisions. I have a .gitignore file configured to skip those files when considering changes.

The stack features an automatic import feature which watches the script directory looking for files that change. If a file changes, then a sync is performed on that individual file (presumably importing some changes). There is a stack level preference to allow a choice of how to handle the situation when a change is detected in both the script and the file (stack {keep stack script/overwrite file}, file {import file}, ask {present options in a dialog}, skip {keep stack script, but do not update the hash nor overwrite the file}).

If automatic import is enabled, there is also an option to have scripts opened in an external editor. When enabled, whenever the IDE wants to edit a script it will also get opened in the chosen external editor. If an object doesn't have a script yet, then a temporary comment is added to create a file for editing.

There is an option to have a sync performed before saving the stack file. This is done with a front script that intercepts the SaveStackRequest message to initiate the sync if required.

The system is designed to be non-destructive, so the way to completely remove a file is to clear the script in the IDE and perform a sync. Deleting a file from the operating system and performing a sync will just regenerate the file. If you remove everything after the header, the file will get removed on the second sync (the first will import the blank script into the IDE, but not remove the file).

The stack currently handles a single mainstack at one time. There is a drop down menu with all non-IDE mainstacks to quickly switch between different ones. Mode 0 stacks are not included in the list. The alt key can be used to add IDE stacks to the menu. Mode 0 stacks can be specified by typing the stack name in the field.

The Prefs substack provides all of the options available for the currently tracked stack and the Script Tracker overall. Changes are saved when the tab is changed or the window is closed. The overall preferences are saved in the same location as the LiveCode prefs (but in a separate file). Stack level preferences are stored in each mainstack as a custom property set.

  • Script Tracker: Options to sync on save and to use external editor.
  • Options: Export method (binfile/file), digest type (MD5/SHA-1), diff context lines, custom property set name
  • Defaults: Initial settings when tracking a stack for the first time. Paths are relative to the mainstack file.
  • Stack: Settings for the stack currently being tracked. If the locations are changed, new locations will be used on the next sync operation. Paths are normally relative to the stack file, but if they start with /, ~, or _: (second character is a :) they will be treated as absolute.
  • Exclusions: Settings for the stack currently being tracked to exclude script export by object type. If exclude is found on the first line of a script, then it will not be exported.

The Log will provide the time taken for an export and list each file that was touched. Some error messages will get displayed there.

Forum Announcement

https://forums.livecode.com/viewtopic.php?f=77&t=31079

Script Index

ScriptTracker.md

GitHub Tracking Setup

  1. Create a repository on GitHub for the project
  2. Clone the empty repository to the development computer
  3. Configure a .gitignore file to exclude these folders:
    • *_Scripts/diff/*
    • *_Scripts/extra/*
  4. Move the latest version of the stack into the new repository
  5. Open the stack in LiveCode
  6. Open ScriptTracker
  7. Select the stack in ScriptTracker (click the Select Stack menu)
  8. (Optional) Adjust the folder names on the Stack tab of Prefs
  9. (Optional) Open the Log window to see results of the exports
  10. Click the Sync Script button to do the initial script export
  11. Stage and commit all of the files
  12. Push changes to the remote (GitHub) repository

ScriptTracker can be configured to perform a sync every time the stack is saved. At any time you will then have everything on disk in a matching state ready to stage and commit to GitHub.

If planning to edit scripts outside of LiveCode, then be sure to enable the Automatic File Import option. This will have ScriptTracker monitor the script folder for changes to the files and automatically perform an import each time.

About

#LiveCode tool to track changes to scripts of a stack

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages