Managing Applescript with git version control

I manage my applescript in github. When we moved to github, we switched all our scripts to .applescript plain text files for git compatibility. We deploy via script, and the deployment scripts parse metadata from the scripts themselves to see the filetype to deploy as (ie, run-only, .scptd, .app, etc) and figure out where they’re deploying to based on the GIT branch, read from the .git/HEAD file.

This works, but there are serious issues. Anything that must contain resources, so deployed as a .app or a .scptd bundle, we’re having the deployment code save over the .scpt file inside the bundle at:
[bundle name].scptd/Contents/Resources/Scripts/main.scpt
But this prevents us from managing the bundled resources on git.
Additionally, for our .apps, I think updating the .scpt inside breaks code signing.
Also, bundle and export settings for Script Debugger aren’t saved with the .applescript file, although we could store those values in the script metadata, parse them out, and set the values via script on export.
Libraries with dictionaries also don’t play nicely with this. The .applescript copy in our git folder won’t compile, because it’s disassociated from the dictionary inside the .scptd.
All in all, it’s a less than ideal solution.

I was excited when I heard that Script Debugger added a feature intended for helping with Version Control. In Preferences → Building, there’s now the checkbox for:

Saving Script Bundles
Save .scptd files in version-control-friendly format
Checking this option causes .scptd files to be saved with their source internally in both .rtf and .scpt format. When opening, the .rtf format is always preferred.

This sounds great - I can use .scptd bundles, AND use git.

But in git, .rtf’s aren’t rendered. Researching this, I found this thread:
[I tried linking, but is says I can’t put links in posts, so I butchered it] forum.latenightsw [com] /t/applescript-support-and-vcs-support/520/40

Which seems to confirm the issue.

Am I missing something? It doesn’t seem practical to merge .rtf’s in git, making this feature not-useful.

Is there a git extension to render rtf’s, instead of displaying the raw markup? A 3rd party merge tool people are using that supports .rtf?

Or from another angle - if the purpose of this feature is Version Control compatibility, why is Script Debugger using a .rtf, if .rtf is not standardly (usefully) compatible with Version Control? If this is the intended use, why not a .applescript text copy of the source inside the bundle, that Script Debugger prioritizes when opening?

I feel like I’m missing something, given that the preferences pane specifies this feature as being specifically for GIT compatibility.

Thanks,

Tom.

I may have found my answer. I looked into github extensions first and found nothing. But now I started looking into third party merge tools; it appears at least Kaleidoscope, Araxis Merge, and Beyond Compare all support .rtf files, so I it looks like I can just go with the .rtf and buy an external merge tool.

Still curious if there’s a reason not to just save the copy of the source inside the bundle as .applescript plaintext though.

In a word, compatibility. Script Debugger can save what it likes in a .scptd bundle, but if that code gets ignored or even lost when opened in another editor, people aren’t going to be happy. Using .rtf lets Script Debugger take advantage of the autosave format and retain full file compatibility.

The only other option would be a custom file format (in effect, by modifying how a .scptd file is handled, or directly). It’s something we’ve discussed several times, but the cons always outweigh the pros.

Thanks Shane. So I reached the right conclusion here - that the intention of the feature is that people would be using an external merge tool that supports rendering rtf to merge?

Pretty much. It was a case of something being better than nothing.

A step by step guide would be great!
Title proposal: Use github to gain version control over my applescripts

Thanks in advance!

Apple’s FileMerge also supports .rtf files.

1 Like