2

ユーザー名をファイルに書き込むためのコミットフックとして実行するPowerShellスクリプトを作成しました。ユーザー名を抽出するためにPowerShellで使用しているコマンドは次のとおりです。

$repodir = "C:\Users\Administrator\Documents\Visual Studio 2012\Projects\testRepo"
cd $repodir
$hguser = hg --cwd $repodir tip | grep user

ここで、$repodirはリポジトリのディレクトリです。PowerShellコマンドラインからコミットすると、フックが実行され、必要に応じてユーザー名が抽出されます。tortoisehgワークベンチ内からコミットすると、フックが実行されますが(出力ファイルに変更が表示されます)、$ hguserに情報がないため、他のhgコマンドも影響しません。tortoisehg内からhgを実行するために必要な特別な構文はありますか?それは正しいパスで実行されていますか?

4

1 に答える 1

2

それは私のために働くようです。

.hg / hgrc

[hooks]
commit = powershell.exe -File "C:\users\andy\desktop\test\test.ps1"

test.ps1

$repodir = "C:\Users\andy\Desktop\Test"
cd $repodir
$hguser = (hg tip) | ? {$_ -match '^user:\s+([\w\s]+\w)'} | % {$matches[1]}
$hguser | Out-File user.txt -Encoding ASCII

user.txtは、TortoiseHg /hg.execommitを介して入力されます。TortoiseHg2.7の使用。

于 2013-03-24T01:04:18.550 に答える