WindowsでGitを使用していて、ワークフローに単体テストを含めようとしています。コミットメッセージにキーワードが含まれている場合。commit-msgフックは、PowershellコマンドをトリガーしていくつかのNunitテストを実行します。
これはフックの私のルビーコードです
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
puts "The commit message is " + message
$regex = /(#runtest)/
if $regex.match(message)
exec 'powershell.exe -ExecutionPolicy RemoteSigned -Command {RunNunitTestCase}'
end
ただし、変更をコミットすると、結果は次のようになります。exec行が実行されましたが、何もしません。
PS D:\testfolder> git commit -am '#runtest'
The commit message is #runtest
[authorupdate b14878d] 123
1 files changed, 1 insertions(+), 0 deletions(-)
私はルビーとPowerShellに不慣れです。このワークフローが実行可能であるか、より良いアプローチがある場合は、遠慮なくコメントしてください。
ありがとうございました。