[英]Can I add a string to my commit messages before sending them to SVN in git-svn?
我的組織有一些愚蠢的要求,你必須在每個SVN提交消息的末尾放置“admin”,以便繞過SVN網守的一些決定,即每個提交應該有一個相關的錯誤號。 (團隊中的每個人都同樣繞過了這個要求。)
我正在嘗試使用git SVN,但我想避免在我頻繁的git-svn提交結束時輸入“admin”。
有沒有辦法讓git SVN為我做這個?
一些想法,但每個都需要一些工作:
你可以設置一個git commit hook,這樣當你提交git時,它會在提交消息中附加"admin"
。 然后當你執行你的git svn dcommit
,你的提交消息已經有了預期的字符串。
在項目的.git
目錄中,將有一個名為hooks
的目錄。
cwd: ~/testrepo/.git/hooks master
λ > ls
applypatch-msg.sample post-update.sample pre-commit.sample prepare-commit-msg.sample
commit-msg.sample pre-applypatch.sample pre-rebase.sample update.sample
您可以查看這些文件, prepare-commit-message.sample
可用於在提交之前編輯提交消息。
制作prepare-commit-message.sample
的副本並將其命名為prepare-commit-message
。
cp prepare-commit-message.sample prepare-commit-message
所以打開那個文件,作為演示,我將這一行添加到最后:
# Append 'admin' to the end of the commit message, $1 is the message passed as argument
echo "admin" >> "$1"
保存更改,退出,嘗試更改並提交。
λ > echo etc >> README
λ > git add .
λ > git commit -m "testing"
[master 89a435d] testing admin
1 files changed, 1 insertions(+), 0 deletions(-)
λ > git log
commit 89a435d5e110229d3c9989bfb464ae2420eb5088
Author: birryree
Date: Fri Oct 28 12:54:20 2011 -0400
testing
admin
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.