2016-11-23 2 views
1

gitコマンドgit logからgithubコミット(テキスト)を電子メールのリンクにする必要があります。したがって、受信者はリンクをクリックして変更に直接行くことができます。シェルスクリプトを使ってgitub "git log"のテキストをpre-fixする方法

私は、テキストと行を含む長いリスト受ける:

commit some_long_string_of_hexadecimals

を、私はにこれを変換する必要があります:私は受け付けており、ログ

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

のn-量が含まれていますこれらのログのうち、このすべてのインスタンス(some_long_string_of_hexadecimals)に対してこれを行うためのスクリプトが必要です。ここで

いくつかの例ログの文です:

commit a98a897a67896a987698a769786a987a6987697a6 
Author: Some Person <[email protected]> 
Date: Thu Sep 29 09:48:52 2016 +0200 

    long message describing change. 

commit a98a897a67896a987698a769786a987a6987697a6 
Author: Some Person <[email protected]> 
Date: Thu Sep 29 09:48:52 2016 +0200 

    more description 

私はそれは次のようになりたいのですが:

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

    added handling of running tests from within a docker container 

どのように私はシェルコマンドを使ってこれを実現するのですか?

ありがとうございます。

+0

あなたが持っているものと変換する必要があるものの具体例を見るとよいでしょう。 –

+0

これは本当にエコー$(gitログ)>> logfile.txt – CodeMonkey

答えて

1
awk '$1 == "commit" {$2 = "https://github.com/account/repo/commit/" $2} 1' 
  1. チェックフィールド1が等しい場合のラインがマッチした場合

  2. あるとして、

  3. そうならば、前付加は2

  4. をフィールドする印刷変更されたライン、他の印刷ラインを "コミット"

+0

優れています。どうもありがとう。 – CodeMonkey

関連する問題