我在python脚本中使用此命令生成一个xml文件,该文件稍后由我们的CI系统处理:
git log -1 --date=iso --pretty=format:"<logentry revision=\"%h\" scm=\"git\">%n<author>%an</author>%n<date>%ad</date>%n<msg>%s</msg>%n"
Run Code Online (Sandbox Code Playgroud)
它以下列格式生成输出
<logentry revision="1e370f5" scm="git">
<author>Johan Govers</author>
<date>2016-02-24 13:11:15 +0100</date>
<msg>PP-204 Try out git PP-207 New build script * Add missing kind="file" to path nodes in changes xml file.</msg>
Run Code Online (Sandbox Code Playgroud)
使用git log -1显示带有换行符的消息但是使用漂亮的格式它们被省略.有没有办法产生如下的输出?
<logentry revision="1e370f5" scm="git">
<author>Johan Govers</author>
<date>2016-02-24 13:11:15 +0100</date>
<msg>PP-204 Try out git
PP-207 New build script
* Add missing kind="file" to path nodes in changes xml file.</msg>
Run Code Online (Sandbox Code Playgroud)
该文档git log告诉我们%s是主题,它是根据提交消息的标题构建的(强调我的):
虽然不是必需的,但最好使用一个简短(小于50个字符)的行来概括更改,然后是空白行,然后是更详尽的描述.提交消息中第一个空白行的文本被视为提交标题,并且该标题在整个Git中使用.例如,git-format-patch [1]将提交转换为电子邮件,它使用Subject行上的标题和正文中的其余提交.
如果要使用整个提交消息,请尝试%B:
%B:生体(未包裹的主体和身体)
| 归档时间: |
|
| 查看次数: |
919 次 |
| 最近记录: |