How to get a list of all Subversion commit author usernames?

前端 未结 8 1545
无人共我
无人共我 2021-01-29 20:51

I\'m looking for an efficient way to get the list of unique commit authors for an SVN repository as a whole, or for a given resource path. I haven\'t been able to find an SVN co

相关标签:
8条回答
  • 2021-01-29 20:59

    A solution for windows 10.

    1. create a batch file printAllAuthor.bat
    @echo off
    for /f "tokens=3" %%a in ('svn log --quiet ^|findstr /r "^r"') do echo %%a
    @echo on
    
    1. run bat file with sort command
    printAllAuthor.bat | sort /unique >author.txt
    

    PS:

    • The step 2 need run the batch file with right path. either set path in %PATH% or use the right OS path format.
    • The step 2 can be made into a batch file as well according to your needs.
    0 讨论(0)
  • 2021-01-29 21:01

    I had to do this in Windows, so I used the Windows port of Super Sed ( http://www.pement.org/sed/ ) - and replaced the AWK & GREP commands:

    svn log --quiet --xml | sed -n -e "s/<\/\?author>//g" -e "/[<>]/!p" | sort | sed "$!N; /^\(.*\)\n\1$/!P; D" > USERS.txt
    

    This uses windows "sort" that might not be present on all machines.

    0 讨论(0)
  • 2021-01-29 21:02

    A simpler alternative:

    find . -name "*cpp" -exec svn log -q {} \;|grep -v "\-\-"|cut -d "|" -f 2|sort|uniq -c|sort -n
    
    0 讨论(0)
  • 2021-01-29 21:05
    svn log  path-to-repo | grep '^r' | grep '|' | awk '{print $3}' | sort | uniq > committers.txt
    

    This command has the additional grep '|' that eliminates false values. Otherwise, Random commits starting with 'r' get included and thus words from commit messages get returned.

    0 讨论(0)
  • 2021-01-29 21:13

    To filter out duplicates, take your output and pipe through: sort | uniq. Thus:

    svn log --quiet | grep "^r" | awk '{print $3}' | sort | uniq
    

    I woud not be surprised if this is the way to do what you ask. Unix tools often expect the user to do fancy processing and analysis with other tools.

    P.S. Come to think of it, you can merge the grep and awk...

    svn log --quiet | awk '/^r/ {print $3}' | sort | uniq
    

    P.P.S. Per Kevin Reid...

    svn log --quiet | awk '/^r/ {print $3}' | sort -u
    

    P3.S. Per kan, using the vertical bars instead of spaces as field separators, to properly handle names with spaces (also updated the Python examples)...

    svn log --quiet | awk -F ' \\\\|' '/^r/ {print $2}' | sort -u
    

    For more efficient, you could do a Perl one-liner. I don't know Perl that well, so I'd wind up doing it in Python:

    #!/usr/bin/env python
    import sys
    authors = set()
    for line in sys.stdin:
        if line[0] == 'r':
            authors.add(line.split('|')[1].strip())
    for author in sorted(authors):
        print(author)
    

    Or, if you wanted counts:

    #!/usr/bin/env python
    from __future__ import print_function # Python 2.6/2.7
    import sys
    authors = {}
    for line in sys.stdin:
        if line[0] != 'r':
            continue
        author = line.split('|')[1].strip()
        authors.setdefault(author, 0)
        authors[author] += 1
    for author in sorted(authors):
        print(author, authors[author])
    

    Then you'd run:

    svn log --quiet | ./authorfilter.py
    
    0 讨论(0)
  • 2021-01-29 21:16

    One a remote repository you can use:

     svn log --quiet https://url/svn/project/ | grep "^r" | awk '{print $3}' | sort | uniq
    
    0 讨论(0)
提交回复
热议问题