在将它们发送到git-svn中的SVN之前,我可以将字符串添加到我的提交消息中吗? [英] Can I add a string to my commit messages before sending them to SVN in git-svn?

查看:143
本文介绍了在将它们发送到git-svn中的SVN之前,我可以将字符串添加到我的提交消息中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的组织有一些愚蠢的要求,你必须在每个SVN提交信息的末尾加上admin,以便绕过由SVN关守做出的每个提交都应该有相关错误号的决定。 (团队中的每个人都同样绕过这个要求。)

My org has some silly requirements that you must put "admin" at the end of every SVN commit message in order to get around some decision made by the SVN gatekeepers that every commit should have an associated bug number. (Everyone on the team bypasses this requirement similarly.)

我试图使用git SVN,但是我想避免将admin放在末尾我的频繁git-svn提交。

I'm trying to use git SVN, but I'd like to avoid putting "admin" at the end of my frequent git-svn commits.

有没有办法让git SVN为我做这件事?

Is there a way to have git SVN do this for me?

推荐答案

你可以设置一个git提交钩子,这样当你提交git时,它会将admin添加到提交消息中。然后当你执行你的 git svn dcommit 时,你的提交信息已经有预期的字符串了。

You can set up a git commit hook, so that when you commit to git, it will append "admin" to the commit message. Then when you do your git svn dcommit, your commit messages will already have the expected string there.

有关git挂钩的文档

在您的项目的 .git 目录中,将会有一个名为 hooks 的目录。

In your project's .git directory, there will be a directory called 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 可以用于在提交消息被提交之前编辑提交消息。

You can take a look at the files, prepare-commit-message.sample can be used to edit commit messages before they are committed.

复制 prepare-commit-message。 sample 并将其称为 prepare-commit-message

Make a copy of prepare-commit-message.sample and call it prepare-commit-message.

cp prepare-commit-message.sample prepare-commit-message

所以打开那个文件,并且作为演示,我将此行添加到最后:

So open that file, and as a demonstration I added this line to the end:

# Append 'admin' to the end of the commit message, $1 is the message passed as argument
echo "admin" >> "$1"

保存更改,退出,尝试更改并提交。

Save changes, exit, try a change, and commit it.

λ > 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

这篇关于在将它们发送到git-svn中的SVN之前,我可以将字符串添加到我的提交消息中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆