git 提交指标

发布于 2024-10-31 21:29:32 字数 591 浏览 1 评论 0原文

我想使用 bash 脚本确定 git 提交指标。
但我从不使用 bash 脚本。

这个想法是在特定时间段内未在其状态中引用的提交数量
(即:未关闭或没有#nnnn引用,其中n是一个数字,因为我们使用Redmine来显示开放提交的引用)

算法是:

fonction (initial date, final date)
  read initial date
  read final date
  int n=0
  while (initial date<date<final date) do 
    if (status!=closed or status!= #nnnn) //where #nnnn is a reference and n a number
      n=+1
    end if
  end while
  echo "the number of none referenced commit is"
  echo n 
  return 0

如果有一个具体的git命令或者其他想法,请留下回复,这对我有很大帮助。谢谢

I want to determine git commit metrics using bash script.
But I never use bash script.

The idea is to have the number of commit wich are not referenced in their status during a specific time
(i.e.: not closed or no #nnnn reference where n is a number, because we use Redmine to show the reference of open commit)

the algorithm is:

fonction (initial date, final date)
  read initial date
  read final date
  int n=0
  while (initial date<date<final date) do 
    if (status!=closed or status!= #nnnn) //where #nnnn is a reference and n a number
      n=+1
    end if
  end while
  echo "the number of none referenced commit is"
  echo n 
  return 0

If there is a specific git command or other idea, please leave a response, it will help me a lot. thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如若梦似彩虹 2024-11-07 21:29:32

这样的脚本将使用和利用 git 低级命令(管道,适合脚本编写)命令 git rev-list

提交限制选项允许您定义一个范围日期,并选择正确的日志消息:

--skip=<number>
    Skip number commits before starting to show the commit output.
--since=<date>
--after=<date>
    Show commits more recent than a specific date.
--until=<date>
--before=<date>
    Show commits older than a specific date.
--max-age=<timestamp>
--min-age=<timestamp>
    Limit the commits output to specified time range.

--grep=<pattern>

将提交输出限制为日志消息与指定模式(正则表达式)匹配的输出。

提交格式选项允许您仅显示您需要的内容,主要是提交的注释,供您解析(我想您在提交的注释中存储了所述状态)提交,尽管您也可以使用 git Notes< /a>):

--pretty[=<format>]
--format=<format>

以给定的格式漂亮地打印提交日志的内容,可以是 oneline、short、medium、full、fuller、email、raw 和 format: 之一。有关每种格式的一些其他详细信息,请参阅“漂亮的格式”部分。省略时,格式默认为中。

Such a script would use and exploit the git low-level commands (plumbing, suitable for scripting) command git rev-list:

The commit limiting options allow you to define a range of date, and to select the right log message:

--skip=<number>
    Skip number commits before starting to show the commit output.
--since=<date>
--after=<date>
    Show commits more recent than a specific date.
--until=<date>
--before=<date>
    Show commits older than a specific date.
--max-age=<timestamp>
--min-age=<timestamp>
    Limit the commits output to specified time range.

--grep=<pattern>

Limit the commits output to ones with log message that matches the specified pattern (regular expression).

The commit formatting options allow you to display only what you need, mainly the comment of the commit, for you to parse (I suppose it is in the comment of a commit that you have stored the status of said commit, although you could also have used git notes):

--pretty[=<format>]
--format=<format>

Pretty-print the contents of the commit logs in a given format, where can be one of oneline, short, medium, full, fuller, email, raw and format:. See the "PRETTY FORMATS" section for some additional details for each format. When omitted, the format defaults to medium.

榆西 2024-11-07 21:29:32

更新评论后:

看来您确实受益于更简单地

git log --oneline | egrep -ivw 'closed|#[0123456789]+'

从提交消息中过滤出常见模式。如果您想要一个计数,

git log --oneline | egrep -ivwc 'closed|#[0123456789]+'

您可以从原始答案标志中添加以减少 git log 的输出,就像这样

git log --oneline --after=2011-01-01 --until=today | egrep -ivwc 'closed|#[0123456789]+'

原始答案:

再来一次。这个问题不解析。 “其状态中未提及” 什么状态?提交通常没有提交。您使用提交注释吗?

我的印象是,您想要查找特定时间段内 git 提交消息中提及的某些信息?如果是这样,请举例说明您使用哪种提交消息,以及如何存储要查找的“关系 ID”列表。例如:

from="3 months ago"
until="1 week ago"

lookforids=( '#bug3' '#update4' '#featureY' )
for lookfor in "${lookforids[@]}";
do
    commitcount=$(git log --no-merges --oneline --after="$from" --until="$until" --all -i --grep="$lookfor" | wc -l)

    if [ "$commitcount" -le 1 ]; then echo "Not referenced: $lookfor"; fi
done

当然,您应该根据您的需求进行混合和匹配,根据您的喜好更改输出。如果您愿意,from/until 当然可以是绝对日期文字。

Update After the comments:

It seems you really are helped by the much simpler

git log --oneline | egrep -ivw 'closed|#[0123456789]+'

filtering out just common patterns from commit messages. If you wanted a count of that

git log --oneline | egrep -ivwc 'closed|#[0123456789]+'

You can add from the original answer flags to reduce the output of git log, like so

git log --oneline --after=2011-01-01 --until=today | egrep -ivwc 'closed|#[0123456789]+'

Original answer:

Come again. This question does not parse. "wich are not referenced in their status" What status? A commit doesn't normally have one. Are you using commit notes?

I'm getting the impression you want to find certain information that was not mentioned in git commit messages during a specific period of time? If so, give examples of what kind of commit messages you use, and how the list of 'relation ids' to look for is stored. E.g.:

from="3 months ago"
until="1 week ago"

lookforids=( '#bug3' '#update4' '#featureY' )
for lookfor in "${lookforids[@]}";
do
    commitcount=$(git log --no-merges --oneline --after="$from" --until="$until" --all -i --grep="$lookfor" | wc -l)

    if [ "$commitcount" -le 1 ]; then echo "Not referenced: $lookfor"; fi
done

Of course you should mix and match to your needs, altering the output to your liking. from/until can of course be absolute date literals if you like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文