0

有什么方法可以获取 SVN 项目的提交数据,如下所示:
commit1 committer commit_time
commit2 commiter commit_time
commit3 committer commit_time

.
.

GIT 的解决方案就在这里!SVN 需要类似的东西

4

2 回答 2

0

正如已经指出的那样,svn log $REPO将为您提供存储库的整个历史记录。您可以使用-r来指定是要从前到后还是从后到前:

$ svn -r1:HEAD $REPO   # Entire repository in chronological order.
$ svn -rHEAD:1 $REPO   # Entire repository in reverse chronological order

这不会得到你想要的输出。相反,您必须使用一些编程来获取并解析它。这是一个例子:

svn log -r1:HEAD $REPO \
    | awk '/^-{72}/ {getline; print $0}' \
    | while IFS="|" read revision author date junk
do
    echo "Author = '$author'  Revision = '$revision' Date = '$date'"
done

这将打印出:

Author = ' Bob '  Revision = 'r1233 '  Date = ' 2013-11-08 09:18:17 -0500 (Fri, 08 Nov 2013) '

请注意 Author 和 Date 周围的额外空格以及 Revision 如何以 an 开头r并具有尾随空格。Plus Date 相当长且令人费解。但是,清理数据并打印出您想要的报告应该不会太难。

您可以做的另一件事是将--xml参数添加到svn log命令中。这将为您提供基于 XML 的输出,可以很容易地被 Perl、PHP、Ruby 或 Python 解析:

<?xml version="1.0" encoding="UTF-8"?>
<log>
<logentry
     revision="1">
<author>Bob</author>
<date>2013-11-13T19:08:19.154858Z</date>
<msg>What I was doing</msg>
</logentry>
<logentry.../>
</log>

而且,Python 和 Perl 的模块也可以以更实用的方式提取这些信息,因此您不必使用 XML 输出。

于 2013-11-13T21:11:45.570 回答
0

svn log将为您完成此任务:

C:\Code>svn help log

log: Show the log messages for a set of revision(s) and/or path(s).
usage: 1. log [PATH][@REV]
       2. log URL[@REV] [PATH...]

  1. Print the log messages for the URL corresponding to PATH
     (default: '.'). If specified, REV is the revision in which the
     URL is first looked up, and the default revision range is REV:1.
     If REV is not specified, the default revision range is BASE:1,
     since the URL might not exist in the HEAD revision.

  2. Print the log messages for the PATHs (default: '.') under URL.
     If specified, REV is the revision in which the URL is first
     looked up, and the default revision range is REV:1; otherwise,
     the URL is looked up in HEAD, and the default revision range is
     HEAD:1.

  Multiple '-c' or '-r' options may be specified (but not a
  combination of '-c' and '-r' options), and mixing of forward and
  reverse ranges is allowed.

  With -v, also print all affected paths with each log message.
  With -q, don't print the log message body itself (note that this is
  compatible with -v).

  Each log message is printed just once, even if more than one of the
  affected paths for that revision were explicitly requested.  Logs
  follow copy history by default.  Use --stop-on-copy to disable this
  behavior, which can be useful for determining branchpoints.

  The --depth option is only valid in combination with the --diff option
  and limits the scope of the displayed diff to the specified depth.

  Examples:
    svn log
    svn log foo.c
    svn log bar.c@42
    svn log http://www.example.com/repo/project/foo.c
    svn log http://www.example.com/repo/project foo.c bar.c
    svn log http://www.example.com/repo/project@50 foo.c bar.c

Valid options:
  -r [--revision] ARG      : ARG (some commands also take ARG1:ARG2 range)
                             A revision argument can be one of:
                                NUMBER       revision number
                                '{' DATE '}' revision at start of the date
                                'HEAD'       latest in repository
                                'BASE'       base rev of item's working copy
                                'COMMITTED'  last commit at or before BASE
                                'PREV'       revision just before COMMITTED
  -q [--quiet]             : print nothing, or only summary information
  -v [--verbose]           : print extra information
  -g [--use-merge-history] : use/display additional information from merge
                             history
  -c [--change] ARG        : the change made in revision ARG
  --targets ARG            : pass contents of file ARG as additional args
  --stop-on-copy           : do not cross copies while traversing history
  --incremental            : give output suitable for concatenation
  --xml                    : output in XML
  -l [--limit] ARG         : maximum number of log entries
  --with-all-revprops      : retrieve all revision properties
  --with-no-revprops       : retrieve no revision properties
  --with-revprop ARG       : retrieve revision property ARG
  --depth ARG              : limit operation by depth ARG ('empty', 'files',
                             'immediates', or 'infinity')
  --diff                   : produce diff output
  --diff-cmd ARG           : use ARG as diff command
  --internal-diff          : override diff-cmd specified in config file
  -x [--extensions] ARG    : Default: '-u'. When Subversion is invoking an
                             external diff program, ARG is simply passed along
                             to the program. But when Subversion is using its
                             default internal diff implementation, or when
                             Subversion is displaying blame annotations, ARG
                             could be any of the following:
                                -u (--unified):
                                   Output 3 lines of unified context.
                                -b (--ignore-space-change):
                                   Ignore changes in the amount of white space.
                                -w (--ignore-all-space):
                                   Ignore all white space.
                                --ignore-eol-style:
                                   Ignore changes in EOL style.
                                -p (--show-c-function):
                                   Show C function name in diff output.

Global options:
  --username ARG           : specify a username ARG
  --password ARG           : specify a password ARG
  --no-auth-cache          : do not cache authentication tokens
  --non-interactive        : do no interactive prompting
  --trust-server-cert      : accept SSL server certificates from unknown
                             certificate authorities without prompting (but only
                             with '--non-interactive')
  --config-dir ARG         : read user configuration files from directory ARG
  --config-option ARG      : set user configuration option in the format:
                                 FILE:SECTION:OPTION=[VALUE]
                             For example:
                                 servers:global:http-library=serf
于 2013-11-13T20:14:14.753 回答