가져 오기 쉬운 Git 커밋 통계
이전에는 주어진 SVN 저장소에 대한 간단한 커밋 통계를 생성하는 TortoiseSvn의 기능을 즐겼습니다. Git에서 무엇을 사용할 수 있는지 궁금하며 특히 관심이 있습니다.
- 사용자 당 커밋 수
- 사용자 당 변경된 줄 수
- 시간 경과에 따른 활동 (예 : 집계 된 주간 변화)
어떤 아이디어?
실제로 git에는 이미 이에 대한 명령이 있습니다.
git shortlog
귀하의 경우에는 다음 양식에 관심이있는 것 같습니다.
git shortlog -sne
--help
다양한 옵션은를 참조하십시오 .
GitStats 프로젝트에 관심이있을 수도 있습니다 . Git 프로젝트에 대한 통계를 포함하여 몇 가지 예가 있습니다. GitStat 메인 페이지에서 :
다음은 현재 생성 된 일부 통계 목록입니다.
- 일반 통계 : 총 파일, 줄, 커밋, 작성자.
- 활동 : 시간, 요일, 시간, 월, 연도 및 연도별로 커밋합니다.
- 작성자 : 작성자 목록 (이름, 커밋 수 (%), 첫 번째 커밋 날짜, 마지막 커밋 날짜, 나이), 월 작성자, 연도 작성자.
- 파일 : 날짜, 확장자 별 파일 수
- 라인 : 날짜 별 코드 라인
첫째, 전체 리포지토리와 전체 히스토리가 로컬에 있기 때문에 네트워크 풀 에서처럼 아무것도 가져올 필요가 없습니다 . 통계를 제공하는 도구가 있다고 확신하지만 때로는 명령 줄로 창의력을 발휘할 수 있습니다. 예를 들어, 이것은 (내 머리에서) 사용자 당 커밋 수를 제공합니다.
git log --pretty=format:%ae \
| gawk -- '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'
요청한 다른 통계에는 더 많은 생각이 필요할 수 있습니다. 사용 가능한 도구를 볼 수 있습니다. 에 대한 인터넷 검색을 git statistics
받는 점을 GitStats
나는 그것이 윈도우에서 실행되는 데 걸리는 무엇을 더 경험하고 더 적은 생각이 없다 도구,하지만 당신은 시도 할 수 있습니다.
지금까지 내가 확인한 최고의 도구는 gitinspector입니다. 사용자 별, 주별 등 설정된 보고서를 제공합니다.
npm으로 아래와 같이 설치할 수 있습니다.
npm install -g gitinspector
링크를 얻는 세부 정보는 다음과 같습니다.
https://www.npmjs.com/package/gitinspector
https://github.com/ejwa/gitinspector/wiki/Documentation
https://github.com/ejwa/gitinspector
예제 명령은 다음과 같습니다.
gitinspector -lmrTw
gitinspector --since=1-1-2017
기타
이 질문에 답 해주신 해커에게 감사드립니다. 그러나 이러한 수정 된 버전이 내 특정 용도에 더 적합하다는 것을 알았습니다.
git log --pretty=format:%an \
| awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'\
| sort -r
(Mac에 gawk가 없으므로 awk를 사용하고 가장 활발한 커미터를 맨 위에 정렬합니다.) 다음과 같은 목록을 출력합니다.
1205 therikss
1026 lsteinth
771 kmoes
720 minielse
507 pagerbak
269 anjohans
205 mfoldbje
188 nstrandb
133 pmoller
58 jronn
10 madjense
3 nlindhol
2 shartvig
2 THERIKSS
다음은 특정 분기 또는 두 개의 해시에 대한 통계를 얻는 방법입니다.
여기서 핵심은 HASH..HASH를 수행하는 기능입니다.
Below I am using the first hash from a branch to the HEAD which is the end of that branch.
Show total commits in a branch
- git log FIRST_HASH..HEAD --pretty=oneline | wc -l
- Output 53
Show total commits per author
- git shortlog FIRST_HASH..HEAD -sne
- Output
- 24 Author Name
- 9 Author Name
Note that, if your repo is on GitHub, you now (May 2013) have a new set of GitHub API to get interesting statistics.
See "File CRUD and repository statistics now available in the API"
That would include:
I've written a small shell script that calculates merge statistics (useful when dealing with a feature-branch-based workflow). Here's an example output on a small repository:
[$]> git merge-stats
% of Total Merges Author # of Merges % of Commits
57.14 Daniel Beardsley 4 5.63
42.85 James Pearson 3 30.00
See this gitstat project
http://mirror.celinuxforum.org/gitstat/
Here is a simple ruby script that I used to get author, lines added, lines removed, and commit count from git. It does not cover commits over time.
Note that I have a trick where it ignores any commit that adds/removes more than 10,000 lines because I assume that this is a code import of some sort, feel free to modify the logic for your needs. You can put the below into a file called gitstats-simple.rb and then run
git log --numstat --pretty='%an' | ruby gitstats-simple.rb
contents of gitstats-simple.rb
#!/usr/bin/ruby
# takes the output of this on stdin: git log --numstat --prety='%an'
map = Hash.new{|h,k| h[k] = [0,0,0]}
who = nil
memo = nil
STDIN.read.split("\n").each do |line|
parts = line.split
next if parts.size == 0
if parts[0].match(/[a-z]+/)
if who && memo[0] + memo[1] < 2000
map[who][0] += memo[0]
map[who][1] += memo[1]
map[who][2] += 1
end
who = parts[0]
memo = [0,0]
next
end
if who
memo[0]+=line[0].to_i
memo[1]+=parts[1].to_i
end
end
puts map.to_a.map{|x| [x[0], x[1][0], x[1][1], x[1][2]]}.sort_by{|x| -x[1] - x[2]}.map{|x|x.inspect.gsub("[", "").gsub("]","")}.join("\n")
DataHero now makes it easy to pull in Github data and get stats. We use it internally to track our progress on each milestone.
https://datahero.com/partners/github/
How we use it internally: https://datahero.com/blog/2013/08/13/managing-github-projects-with-datahero/
Disclosure: I work for DataHero
You can use gitlogged gem (https://github.com/dexcodeinc/gitlogged) to get activities by author and date. This will give you report like this:
gitlogged 2016-04-25 2016-04-26
which returns the following output
################################################################
Date: 2016-04-25
Yunan (4):
fix attachment form for IE (#4407)
fix (#4406)
fix merge & indentation attachment form
fix (#4394) unexpected after edit wo
gilang (1):
#4404 fix orders cart
################################################################
################################################################
Date: 2016-04-26
Armin Primadi (2):
Fix document approval logs controller
Adding git tool to generate summary on what each devs are doing on a given day for reporting purpose
Budi (1):
remove validation user for Invoice Processing feature
Yunan (3):
fix attachment in edit mode (#4405) && (#4430)
fix label attachment on IE (#4407)
fix void method (#4427)
gilang (2):
Fix show products list in discussion summary
#4437 define CApproved_NR status id in order
################################################################
Modify https://stackoverflow.com/a/18797915/3243930 . the output is much closed to the graph data of github.
#!/usr/bin/ruby
# takes the output of this on stdin: git log --numstat --prety='%an'
map = Hash.new{|h,k| h[k] = [0,0,0]}
who = nil
memo = nil
STDIN.read.split("\n").each do |line|
parts = line.split("\t")
next if parts.size == 0
if parts[0].match(/[a-zA-Z]+|[^\u0000-\u007F]+/)
if who
map[who][0] += memo[0]
map[who][1] += memo[1]
if memo[0] > 0 || memo[1] > 0
map[who][2] += 1
end
end
who = parts[0]
memo = [0,0]
next
end
if who
memo[0]+=parts[0].to_i
memo[1]+=parts[1].to_i
end
end
puts map.to_a.map{|x| [x[0], x[1][0], x[1][1], x[1][2]]}.sort_by{|x| -x[1] - x[2]}.map{|x|x.inspect.gsub("[", "").gsub("]","")}.join("\n")
참고URL : https://stackoverflow.com/questions/1486819/which-git-commit-stats-are-easy-to-pull
'developer tip' 카테고리의 다른 글
다른 그루비에 그루비 스크립트 포함 (0) | 2020.09.11 |
---|---|
디버그에서 애플리케이션 인사이트 비활성화 (0) | 2020.09.11 |
서버 127.0.0.1 shell / mongo.js에 연결할 수 없습니다. (0) | 2020.09.11 |
Python egg 파일을 만드는 방법 (0) | 2020.09.10 |
PostgreSQL의 함수 내에서 SELECT 결과를 반환하는 방법은 무엇입니까? (0) | 2020.09.10 |