簡體   English   中英

如何以自定義漂亮的日志格式在每個新行上附加選項卡?

[英]How to append tab on every new line in a custom pretty log format?

我一直在嘗試使用 Git 日志進行哪些自定義,我想我已經確定了適合我的日志。 但是,我不確定如何標記整個 git 消息。 我可以在第一行完成,並且我假設整個 git 消息是一個長字符串。

另外,是否可以像 Git log default 那樣輸出整個 git commit 消息? 也就是說,消息的每行 1 行。

默認的 Git 日志:

commit 3246e9dfcf80d8edada9a559684b528658b8ccf5
Author: Reid
Date:   Thu Jun 9 16:30:35 2016 -0400

    Refactored Loading Indicators

commit 219a67a34036b40d18091ea3a1df6417c5feb245
Author: Reid
Date:   Fri Jun 3 14:50:59 2016 -0400

    Filter out Promotions < 0
    Submission of Promo Code working with error messages
    Refactored Loading Indicators
    Limit 1 promo code per order via Mini Cart
    Cart stays open if they change quantity of item
    Migrated Drawer Animation to an Extension
    Hooked into hideAllNavigation()
    Dynamically Set Items Container Height
    Implement the Mini Cart Experience Flag

我的自定義 git 日志格式:

3246e9d 2016-06-09 [Reid]

        Refactored Loading Indicators

219a67a 2016-06-03 [Reid]

        Filter out Promotions < 0 Submission of Promo Code working with error messages Refactored Loading Indicators Limit 1 promo code per order via Mini Cart Cart stays open if they change quantity of item Migrated Drawer Animation to an Extension Hooked into hideAllNavigation() Dynamically Set Items Container Height Implement the Mini Cart Experience Flag

我在 git config 中的自定義 git log 別名:

[alias]
    logg = log --pretty=format:'%C(197)%h%Creset %C(039)%ad%Creset %C(177)[%an <%ae>]%Creset%n%n\t%s%n' --date=short

根據git-log聯機幫助頁 ,其中一個格式字符是:

%x00:從十六進制代碼中打印一個字節

由於x09是\\ t的十六進制代碼,因此可以插入%x09 ,它將表示制表符。

我找到了,只是追加前。 %w(80,9,9)在您要格式化的文本選擇之前。 寬度是第一個#,第二個是第一行縮進,第三個是每隔一行的縮進。

鏈接以幫助描述解決方案。

https://git-scm.com/docs/git-shortlog

重現git log的默認行為的最准確方法是使用%w和換行 = 0,它縮進行而不換行(每個git shortlog ),並使用%B獲取原始提交文本,即使它沒有不符合 Git 理想的“主題行LF正文”標准。

%w(0,4,4)%B

這是英文的完整“中等”日志格式:

%C(yellow)commit%C(auto) %H%d%nAuthor: %aN <%aE>%nDate:   %ad%n%n%w(0,4,4)%B

示例輸出:

commit f7c28ecb35b64970f1af8f05fd644fb4bf663e2a (HEAD -> main, origin/main)
Author: Joel Spolsky
Date:   Wed Oct 08 19:45:20 2003 -0500

    The Absolute Minimum Every Software Developer 
    Absolutely, Positively Must Know About Unicode
    and Character Sets (No Excuses!)

    IT’S NOT THAT HARD.

(注意:此格式省略了合並父項,沒有具體的格式代碼。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM