编译有关项目的历史信息(尤其是 SLOC)

发布于 2024-08-11 18:02:10 字数 334 浏览 6 评论 0原文

我正在寻找一种工具来帮助我编译给定项目的某些代码指标的历史记录。

该项目存储在一个 Mercurial 存储库中,并且有大约一百个修订。我正在寻找这样的东西:

  • 检查每个修订版
  • 计算指标并将它们存储在带有修订版标识符的地方,
  • 与下一个修订版执行相同的操作

首先,计算 SLOC 就足够了,但分析#也很好 )

我知道这些事情通常由 CI 服务器处理,但是我独自完成这个项目,因此没有费心去设置 CI 服务器(我想使用 TeamCity,但我真的没有 一开始就看不到这样做的好处)。如果我现在设置 CI 服务器,它可以处理这个问题吗?

I am looking for a tool that will help me to compile a history of certain code metrics for a given project.

The project is stored inside a mercurial repository and has about a hundred revisions. I am looking for something that:

  • checks out each revision
  • computes the metrics and stores them somewhere with an identifier of the revision
  • does the same with the next revisions

For a start, counting SLOCs would be sufficient, but it would also be nice to analyze # of Tests,TestCoverage etc.

I know such things are usually handled by a CI Server, however I am solo on this project and thus haven't bothered to set up a CI Server (I'd like to use TeamCity but I really didn't see the benefit of doing so in the beginnig). If I'd set up my CI Server now, could it handle that?

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

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

发布评论

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

评论(3

夜雨飘雪 2024-08-18 18:02:10

根据 jitter 的建议,我编写了一个在 cygwin 内运行的小 bash 脚本,使用 sloccount 来计算源代码行数。输出只是转储到文本文件中:

 #!/bin/bash
COUNT=0 #startrev
STOPATREV = 98
until [ $COUNT -gt $STOPATREV ]; do
        hg update -C -r $COUNT >> sloc.log # update and log
        echo "" >> sloc.log # echo a newline
        rm -r lib # dont count lib folder
        sloccount /thisIsTheSourcePath | print_sum
        let COUNT=COUNT+1
done 

According to jitter's suggestion I have written a small bash script running inside cygwin using sloccount for counting the source lines. The output was simply dumped to a textfile:

 #!/bin/bash
COUNT=0 #startrev
STOPATREV = 98
until [ $COUNT -gt $STOPATREV ]; do
        hg update -C -r $COUNT >> sloc.log # update and log
        echo "" >> sloc.log # echo a newline
        rm -r lib # dont count lib folder
        sloccount /thisIsTheSourcePath | print_sum
        let COUNT=COUNT+1
done 
情绪失控 2024-08-18 18:02:10

您可以编写一个例如 shell 脚本来

  1. 检查第一个版本
  2. ,在其上运行 sloccount (保存输出)
  3. 检查出下一个版本,
  4. 重复步骤 2-4

或者查看 ohloh ,它现在似乎有 Mercurial 支持。

否则不知道有任何支持mercurial的SCM统计工具。由于 Mercurial 相对较新(自 2005 年以来),可能需要一些时间才能支持此类“次要用例”。 (提示:也许您自己提供一个 hgstat 库,因为 svn 和 csv 都有)

You could write a e.g. shell script which

  1. checks out first version
  2. run sloccount on it (save output)
  3. check out next version
  4. repeat steps 2-4

Or look into ohloh which seems to have mercurial support by now.

Otherwise I don't know of any SCM statistics tool which supports mercurial. As mercurial is relatively young (since 2005) it might take some time until such "secondary use cases" are supported. (HINT: maybe provide a hgstat library yourself as there are for svn and csv)

无声静候 2024-08-18 18:02:10

如果是我编写软件来执行此类操作,我想我会将项目的指标结果转储到单个文件中,并对其进行修订控制。然后,“历史分析”工具必须提取该一个文件的旧版本,而不是每次都必须提取整个存储库的每个旧副本并重新运行所有测试。

If it were me writing software to do that kind of thing, I think I'd dump metrics results for the project into a single file, and revision control that. Then the "historical analysis" tool would have to pull out old versions of just that one file, rather than having to pull out every old copy of the entire repository and rerun all the tests every time.

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