Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何在github中预先修复一段文本;吉特日志;使用shell脚本_Regex_Git_Bash_Shell_Git Log - Fatal编程技术网

Regex 如何在github中预先修复一段文本;吉特日志;使用shell脚本

Regex 如何在github中预先修复一段文本;吉特日志;使用shell脚本,regex,git,bash,shell,git-log,Regex,Git,Bash,Shell,Git Log,我需要从git命令git log将github提交(文本)到电子邮件中的链接中。因此,收件人可以单击链接并直接转到更改 我收到一个长长的列表,其中包含以下文字行: 提交一些长字符串(由十六进制组成) 我需要将其转化为: 提交https://github.com/account/repo/commit/some_long_string_of_hexadecimals 我正在接收的日志包含n个日志,因此我需要脚本来为所有实例(一些长字符串,由十六进制组成)执行此操作 以下是几个日志语句示例: com

我需要从git命令
git log
将github提交(文本)到电子邮件中的链接中。因此,收件人可以单击链接并直接转到更改

我收到一个长长的列表,其中包含以下文字行:

提交一些长字符串(由十六进制组成)

我需要将其转化为:

提交https://github.com/account/repo/commit/some_long_string_of_hexadecimals

我正在接收的日志包含n个日志,因此我需要脚本来为所有实例(一些长字符串,由十六进制组成)执行此操作

以下是几个日志语句示例:

commit a98a897a67896a987698a769786a987a6987697a6
Author: Some Person <some@email.com>
Date:   Thu Sep 29 09:48:52 2016 +0200

    long message describing change.

commit a98a897a67896a987698a769786a987a6987697a6
Author: Some Person <some@email.com>
Date:   Thu Sep 29 09:48:52 2016 +0200

    more description
提交A98A897A67896A987698A76976A987A6987697A6
作者:某个人
日期:2016年9月29日星期四09:48:52+0200
描述变化的长消息。
提交A98A897A67896A987698A76976A987A6987697A6
作者:某个人
日期:2016年9月29日星期四09:48:52+0200
更多描述
我希望它看起来像这样:

commit https://github.com/account/repo/commit/a98a897a67896a987698a769786a987a6987697a6
Author: Some Person <some@email.com>
Date:   Thu Sep 29 09:48:52 2016 +0200

    added handling of running tests from within a docker container
提交https://github.com/account/repo/commit/a98a897a67896a987698a769786a987a6987697a6
作者:某个人
日期:2016年9月29日星期四09:48:52+0200
添加了从docker容器中运行测试的处理
如何使用shell命令实现这一点

提前谢谢

awk '$1 == "commit" {$2 = "https://github.com/account/repo/commit/" $2} 1'
  • 检查字段1是否等于“提交”

  • 如果是,请在字段2前加上前缀

  • 如果行匹配,则打印修改的行,否则按原样打印行

  • 检查字段1是否等于“提交”

  • 如果是,请在字段2前加上前缀

  • 如果行匹配,则打印修改的行,否则按原样打印行


  • 最好能看到一个具体的例子,说明你拥有什么以及你需要将它转换成什么。它实际上只是echo$(git log)>>logfile.txt最好能看到一个具体的例子,说明你拥有什么以及你需要将它转换成什么。它实际上只是echo$(git log)>>logfile.txt