dinoboff / github-tools

Helpers for hosting python projects on GitHub
http://dinoboff.github.com/github-tools/
BSD 2-Clause "Simplified" License
87 stars 6 forks source link

github-tools is incompatible with GitPython 0.2.0-beta1 #16

Closed danmackinlay closed 14 years ago

danmackinlay commented 14 years ago

(formerly: "paver gh_pages_create throws an AttributeError: 'function' object has no attribute 'endswith')

On a fresh checkout of github-tools I get weird behaviour on working though the instructions in the readme file. When I get to the step paver gh_pages_create, i get a nasty traceback:

$ paver gh_pages_create
---> github.tools.task.gh_pages_create

Captured Task Output:
---------------------

---> github.tools.task.gh_pages_create
Traceback (most recent call last):
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/paver/tasks.py", line 170, in _run_task
    return do_task()
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/paver/tasks.py", line 167, in do_task
    return func(**kw)
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/github/tools/task.py", line 115, in gh_pages_create
    repo = _get_repo(os.getcwd())
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/github/tools/task.py", line 81, in _get_repo
    return GitHubRepo(working_copy)
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/github/tools/gh_pages.py", line 184, in __init__
    super(GitHubRepo, self).__init__(path)
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/github/tools/gh_pages.py", line 162, in __init__
    self.submodules = SubmoduleDict(self)
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/github/tools/gh_pages.py", line 277, in __init__
    self._get_submodules()
  File "/Users/dan/.virtualenvs/dntest/lib/python2.6/site-packages/github/tools/gh_pages.py", line 303, in _get_submodules
    gitmodule = os.path.join(self.repo.git.git_dir, '.gitmodules')
  File "/Users/dan/.virtualenvs/dntest/bin/../lib/python2.6/posixpath.py", line 67, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'function' object has no attribute 'endswith'

Dropping into the debugger... the problem in gh_pages.py seems to occur on line 304:

    gitmodule = os.path.join(self.repo.git.git_dir, '.gitmodules')     

AFAICT that will return a lambda which when called executes the fucntion git-dir against the site repo, which doesn't seem right. It seems like that line should be something like

    gitmodule = os.path.join(self.repo.working_dir, '.gitmodules')     

Then we need to update line 228 from

    index = os.path.join(gh_pages.path, 'index')

to

    index = os.path.join(gh_pages.working_dir, 'index')

for the same reason, i.e. api differences between the expected and supplied gitpython Repo object. Assuming i can attach things to github issues I'll attach a diff to that effect.

on my system, if i make those changes i then get a nasty uninformative error:

$  paver gh_pages_create
---> github.tools.task.gh_pages_create
Create a submodule at docs/_build/html and a gh-pages root branch to host your gh-pages...
Traceback (most recent call last):
  File "/Users/dan/.virtualenvs/dntest/bin/paver", line 8, in <module>
    load_entry_point('Paver==1.0.2', 'console_scripts', 'paver')()
SystemExit

which may be about my git throwing nasty errors or something? My time to debug this is momentarily at an end, however, so let's see if I'm just doing something stupid first.

Anyway, there's something awry here with gitpython api. import git; git.version reports "0.2.0-beta1" - is the solution here as simple as pegging the version of gitpython in the requirements to 0.1?

danmackinlay commented 14 years ago

Yep, while I may not be able to attach diffs, I will hold off doing so until there is a policy call fro you on this one. Forcing GitPython==0.1.6 causes github-tools to work perfectly (not even any nasty SystemExits). So I suspect requires.txt needs to ahve the line

GitPython>=0.1.6

changed to be

GitPython==0.1.6

Or is tracking the new GitPython desirable?

dinoboff commented 14 years ago

I changed GitPython requirement. Requires version 1.6 specifically.

github-tools 0.3 will track GitPython 2.x.

dinoboff commented 14 years ago

I will fix issue 17 and release 0.2 with the fix. Then I will apply your changes.

Thanks.

danmackinlay commented 14 years ago

Thanks for that terrifyingly fast fix!