簡體   English   中英

git 預推掛鈎不適用於 visual studio git 界面

[英]git pre-push hook doesn't work with visual studio git interface

如果包含字符串“NDI”的項目已更改,我已經創建了一個運行所有單元測試 (NUint) 的預推掛鈎。

#!/bin/bash

# Get the current branch
branch=$(git rev-parse --abbrev-ref HEAD)

# Get the remote repository and branch
remote=$(git config --get branch.$branch.remote)
remote_branch=$(git config --get branch.$branch.merge | sed 's#^refs/heads/##')

# Check if any project containing "NDI" in its name has changed
if git diff --name-only $remote/$remote_branch HEAD | grep -q "NDI"; then
  # Run all NUnit tests
  dotnet test
fi

# If the tests failed, cancel the push
if [ $? -ne 0 ]
then
  echo "Tests failed. Push cancelled."
  exit 1
fi

問題是當我嘗試使用 visual studio git 界面將新代碼推送到遠程存儲庫時,我收到錯誤消息: “無法推送到遠程存儲庫。有關詳細信息,請參閱 Output window。”
output window 沒有任何關於問題的特殊消息,只是關於從提交成功構建。 當我嘗試將 VS 終端與git push一起使用時,如果 NDI 項目已更改,它會正常工作並成功運行單元測試。
旁注:對於預提交掛鈎,它按預期工作。

截至今天,公認這是一個錯誤,目前微軟正在考慮修復它。 修復錯誤的決定將取決於受該問題影響的人數。
同時,建議嘗試變通解決方案或“關注問題單並對其進行投票”- Microsoft,以幫助確定修復的優先級。

論壇問題鏈接: https://developercommunity.visualstudio.com/t/Failed-to-push-to-the-remote-repository/10238402

我會盡量更新這個答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM