trac-hacks / tracstats

Project and source code statistics plugin for Trac.
http://trac-hacks.org/wiki/TracStatsPlugin
Other
20 stars 13 forks source link

Add git support #24

Closed mathroc closed 13 years ago

mathroc commented 13 years ago

when instaling tracstats with git repostories, (trac 0.12, two git repositories) i got:

wiki pages and tickets are (obviously) fine.

I don't have much knowledge programming with python or trac but I'm willing to look into it if you someone can tell me where to start looking. and if possible a brief todo list/pointers.

argoyle commented 13 years ago

I use tracstats with Git and I have found out that the repository needs to be cached to make it work (cached_repository = true and persistent_cache = true).

You probably need to run trac-admin repository resync after the change.

mathroc commented 13 years ago

well after 'trac-admin /data/trac/$env changeset added $repo $rev' had been invoked by a hook it almost worked.

/stats was working but not /stats/code

i just commented out subversion specific code and it worked:

mathieu@evangeneer tracstats:master $ git diff
diff --git a/tracstats/web_ui.py b/tracstats/web_ui.py
index a0e93a7..6b5b5d5 100644
--- a/tracstats/web_ui.py
+++ b/tracstats/web_ui.py
@@ -404,11 +404,11 @@ class TracStatsPlugin(Component):

         # Convert the revision field from text to a number... this might
         # break with DVCS-type SHA hashes.
-        if RepositoryManager(self.env).repository_type == 'svn':
-            revisions = [(int(rev), t, author, msg, repos)
-                         for rev, t, author, msg, repos in revisions]
-            changes = [(int(rev), path, change_type, author)
-                        for rev, path, change_type, author in changes]
+        #if RepositoryManager(self.env).repository_type == 'svn':
+        #    revisions = [(int(rev), t, author, msg, repos)
+        #                 for rev, t, author, msg, repos in revisions]
+        #    changes = [(int(rev), path, change_type, author)
+        #                for rev, path, change_type, author in changes]

         if revisions:
             head = revisions[0]
mrjbq7 commented 13 years ago

I'm curious why the "svn" code caused you an error, if you are using git.

I've tested with git and everything appears to be working (although often the git users don't map properly to trac users, but that is a GitPlugin configuration issue).

mathroc commented 13 years ago

well that seems weird to me too but trac aws complaining about one of those line ..

I don't know python at all, if you can tell me how to print "RepositoryManager(self.env).repository_type" in a trac webpage of the plugin I could check if the repository_type reported is the good one. when I'll got access to this omputer again I'll also try to un-comment thoses lines to see if it's a syntax error. trac might be using python3 (need to verify), I don't know if it's relevant

mrjbq7 commented 13 years ago

I removed this "svn" piece of code as it conflicts a bit with the Trac 0.12 style of multiple repositories.