サクラエディタで svn|git log/blame
サクラエディタで、現在のファイルに対して、 svn|git log と svn|git blame を発行するマクロです。
\\192.168.x.x 形式へは git.exeとか svn.exe が対応していないので、 mount -t cifs で逆にマウントするか、ネットワークフォルダ割り当てをしてください。
個のルーチンを動かすには、svnまたは、gitが必要です。
GIT
https://git-for-windows.github.io/
SVN
https://www.softel.co.jp/blogs/tech/archives/4667
このルーチンには表示時にバグが1つあります。
サクラエディタはケチなので toSJIS関数をマクロから使わせてくれないので、一部日本語が文字化けすることがあります。
たとえば、 ソースコードを UTF-8で書いていると、 blameとかの結果が文字化けします。
これは、サクラエディタが、外部出力はShift-JISを要求しているのにもかかわらず、 ToSJIS 変換ルーチンをマクロへ提供していないためです。
//サクラエディタで svn|git log/blame // //現在、編集しているファイルの履歴を表示 // //作った人 rti7743 //ライセンス: NYSL / CC0 / Public Domain / ご自由に //コマンドを実行して、その結果から、特定の文字列を含まない行だけを取得. //return `cmd | grep -v foo`; // //バグ: サクラエディタはケチなので toSJIS関数をマクロから使わせてくれないので、一部日本語が文字化けすることがあります。 function system(cmd,ignoreMessageArray) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var shell = new ActiveXObject("WScript.Shell"); var stdout = fso.GetTempName(); // var stdout="c:\\temp\\aa.txt"; cmd = "cmd.exe /c " + cmd + " > \"" + stdout + "\" 2>&1"; shell.Run(cmd,0,1); var result = ""; var fs = fso.OpenTextFile(stdout,1); while(! fs.AtEndOfStream ) { var line = fs.ReadLine(); var found = false; for(var i in ignoreMessageArray) { if ( line.indexOf( ignoreMessageArray[i] ) >= 0) { found = true; } } if (found) { continue; } result += line + "\r\n"; } fs.Close(); fso.DeleteFile(stdout); return result; } function main() { var filename = "\"" + Editor.GetFilename() + "\""; var result = ""; var cmd=""; //GIT //DOWNLOAD https://git-for-windows.github.io/ cmd = "git log " + filename; result = system(cmd,["Not a git repository"] ); if (result.length > 0) { Editor.TraceOut(result,2); ActivateWinOutput(); cmd = "git blame " + filename; result = system(cmd,[] ); Editor.TraceOut(result,2); return ; } //SVN //DOWNLOAD https://www.softel.co.jp/blogs/tech/archives/4667 cmd = "svn log " + filename; result = system(cmd,["is not a working copy"] ); if (result.length > 0) { Editor.TraceOut(result,2); ActivateWinOutput(); cmd = "svn blame " + filename; result = system(cmd,[] ); Editor.TraceOut(result,2); return ; } } main();