如何使用shell脚本在GitHub "git log"中预先修复一段文本



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

我收到一个包含文本的行的长列表:

commit some_long_string_of_hexadecimals

我需要将其转换为:

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

我收到的日志包含这些日志的n-amount,因此我需要脚本来完成此操作(some_long_string_of_hexadecimals)。

这是一些示例日志语句:

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

我希望它看起来像这样:

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

如何使用shell命令实现此目标?

预先感谢。

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

  2. 如果是这样,请预先登录2

  3. 如果行匹配,请打印修改线,否则打印行

最新更新