Permalink
Browse files

sort user commits across all projects

  • Loading branch information...
1 parent f0d98bd commit 4aa9d6aff1dc4d816f5e10df8fae2e3c966972fe @igrigorik committed Jan 23, 2009
Showing with 40 additions and 33 deletions.
  1. +1 −1 .gitignore
  2. +39 −32 gitter.rb
View
2 .gitignore
@@ -1,2 +1,2 @@
nbproject
-user-history
+user-history*
View
71 gitter.rb
@@ -34,6 +34,7 @@ def to_rfc2822
# A tests/bug_curb_easy_blocks_ruby_threads.rb
# D ext/ectconf_old.rb
+user_commits = []
userdata["repositories"].each do |repo|
repodata = JSON.parse(open("http://github.com/api/v1/json/#{username}/#{repo["name"]}/commits/master").read)
@@ -56,41 +57,47 @@ def to_rfc2822
next if commit["committer"]["email"] != userdata["email"]
puts "#{repo["name"]}: #{commit["id"]}"
+ commitdata = JSON.parse(open("http://github.com/api/v1/json/#{username}/#{repo["name"]}/commit/#{commit["id"]}").read)["commit"]
+
+ commit["committed_date"] = DateTime.parse(commit["committed_date"])
+ commit["details"] = commitdata
- history.write("\n\n------------------------------------------------------------------------\n")
- history.write("r#{commit["id"][0,7]} | #{commit["committer"]["email"]} | ")
- history.write("#{DateTime.parse(commit["committed_date"]).strftime("%Y-%m-%d %H:%M:%S %Z")} ")
- history.write("(#{DateTime.parse(commit["committed_date"]).to_rfc2822}) | ")
- history.write("x lines\n")
- history.write("Changed paths:")
+ user_commits.push commit
+ end
+end
- commitdata = JSON.parse(open("http://github.com/api/v1/json/#{username}/#{repo["name"]}/commit/#{commit["id"]}").read)["commit"]
+user_commits.sort_by {|c| c["committed_date"]}
+user_commits.each do |commit|
- # Sample commit drilldown from API (JSON):
- # {
- # {"removed": [{"filename": "commands.rb"}, {"filename": "helpers.rb"}],
- # "added": [{"filename": "commands/commands.rb"}, {"filename": "commands/helpers.rb"}],
- # "message": "move commands.rb and helpers.rb into commands/ dir",
- # "modified": [{"diff": "@@ -56,7 +56,7 @@ ..."}],
- # "parents": [{"id": "d462d2a2e60438ded3dd9e8e6593ca4146c5a0ba"}],
- # "url": "http://github.com/defunkt/github-gem/commit/c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b",
- # "author": {"name": "Chris Wanstrath", "email": "chris@ozmm.org"},
- # "id": "c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b",
- # "committed_date": "2008-03-02T16:45:41-08:00",
- # "authored_date": "2008-03-02T16:45:41-08:00",
- # "tree": "28a1a1ca3e663d35ba8bf07d3f1781af71359b76",
- # "committer": {"name": "Chris Wanstrath", "email": "chris@ozmm.org"}}}
- # }
-
- %w(added removed modified).each do |action|
- commitdata[action].each do |file|
- history.write("\n#{action[0,1].capitalize} #{file["filename"]}")
- end
- end
+ history.write("\n\n------------------------------------------------------------------------\n")
+ history.write("r#{commit["id"][0,7]} | #{commit["committer"]["email"]} | ")
+ history.write("#{commit["committed_date"].strftime("%Y-%m-%d %H:%M:%S %Z")} ")
+ history.write("(#{commit["committed_date"].to_rfc2822}) | ")
+ history.write("x lines\n")
+ history.write("Changed paths:")
- end
-
- # convert git logs to code_swarm XML format (make sure codeswarm/bin is in your path)
- `#{codeswarm_path}/bin/convert_logs.py -g user-history.log -o user-history.log.xml`
+ # Sample commit drilldown from API (JSON):
+ # {
+ # {"removed": [{"filename": "commands.rb"}, {"filename": "helpers.rb"}],
+ # "added": [{"filename": "commands/commands.rb"}, {"filename": "commands/helpers.rb"}],
+ # "message": "move commands.rb and helpers.rb into commands/ dir",
+ # "modified": [{"diff": "@@ -56,7 +56,7 @@ ..."}],
+ # "parents": [{"id": "d462d2a2e60438ded3dd9e8e6593ca4146c5a0ba"}],
+ # "url": "http://github.com/defunkt/github-gem/commit/c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b",
+ # "author": {"name": "Chris Wanstrath", "email": "chris@ozmm.org"},
+ # "id": "c26d4ce9807ecf57d3f9eefe19ae64e75bcaaa8b",
+ # "committed_date": "2008-03-02T16:45:41-08:00",
+ # "authored_date": "2008-03-02T16:45:41-08:00",
+ # "tree": "28a1a1ca3e663d35ba8bf07d3f1781af71359b76",
+ # "committer": {"name": "Chris Wanstrath", "email": "chris@ozmm.org"}}}
+ # }
+ %w(added removed modified).each do |action|
+ commit["details"][action].each do |file|
+ history.write("\n#{action[0,1].capitalize} #{file["filename"]}")
+ end
+ end
end
+
+# convert git logs to code_swarm XML format (make sure codeswarm/bin is in your path)
+`#{codeswarm_path}/bin/convert_logs.py -g user-history.log -o user-history.log.xml`

0 comments on commit 4aa9d6a

Please sign in to comment.