Created
December 19, 2013 09:28
-
-
Save TakamiChie/8036668 to your computer and use it in GitHub Desktop.
GinnieからGitExtensionsを起動しコミットするスクリプト ref: http://qiita.com/TakamiChie/items/8b5881c9d2dbe3a6d28c
This file contains 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
var wsh = new ActiveXObject("WScript.Shell"); | |
var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
var command = App.ParamCount > 0 ? App.Params(0) : "commit"; | |
var path = fso.buildPath(wsh.RegRead("HKCU\\Software\\GitExtensions\\InstallDir"), "GitExtensions.exe") | |
if(fso.fileExists(path)){ | |
// .gitフォルダを探索 | |
var doc = Documents.newDocument(); | |
if(doc.save()){ | |
var folder = fso.getFolder(fso.getParentFolderName(doc.fileName)) | |
try{ | |
while(!fso.folderExists(fso.buildPath(folder.path, ".git"))){ | |
folder = folder.parentFolder; | |
} | |
var shell = new ActiveXObject("WScript.Shell"); | |
shell.run(format("\"{0}\" {1} \"{2}\"", path, command, folder.path)); | |
}catch(e){ | |
Dialogs.Alert("リポジトリルートフォルダが発見できませんでした。リポジトリではない可能性があります\n" + e.message); | |
} | |
} | |
}else{ | |
Dialogs.Alert("Git Extensionsがインストールされていません"); | |
} | |
App.Quit(); | |
function format(string) | |
{ | |
var text = string; | |
for(var i = 1; i < arguments.length; i++) | |
{ | |
text = text.replace("{" + (i - 1) + "}", arguments[i]); | |
} | |
return text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment