Created
February 7, 2012 22:14
-
-
Save ccgus/1762511 to your computer and use it in GitHub Desktop.
Auto-gitify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function runGitWithArgsForDocument(document, args) { | |
task = NSTask.alloc().init().autorelease(); | |
task.setCurrentDirectoryPath(document.fileURL().path()); | |
task.setLaunchPath('/usr/bin/git'); | |
task.setArguments(args); | |
task.launch(); | |
task.waitUntilExit(); | |
} | |
function documentWasOpened(document) { | |
var docURL = document.fileURL(); | |
var gitURL = docURL.URLByAppendingPathComponent_('.git'); | |
var fm = NSFileManager.defaultManager(); | |
if (!fm.fileExistsAtPath_(gitURL.path())) { | |
print("Making the git repository"); | |
runGitWithArgsForDocument(document, ['init']); | |
runGitWithArgsForDocument(document, ['add', 'pages', 'properties.plist', 'storeinfo.plist']); | |
runGitWithArgsForDocument(document, ['commit', '-m', 'First Commit']); | |
} | |
} | |
function documentWillClose(document) { | |
// adding pages again will just add any new pages that didn't already exist. | |
runGitWithArgsForDocument(document, ['add', 'pages']); | |
runGitWithArgsForDocument(document, ['commit', '-a', '-m', 'document close']); | |
} | |
function documentWasClosed(documentPath) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment