Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11297 closed enhancement (fixed)

Allow root of repository to be specified for Git repository directory

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.2
Component: plugin/git Version: 1.0-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Git repository will be discovered when the parent of a .git directory in a non-bare repository is specified.

API Changes:
Internal Changes:

Description

If we have a Git repository in /home/user/Workspace/t11295/teo-rjollos.git/ and set the Directory through the web admin page to this path, we are initially given no indication that this is incorrect. When resyncing, there is a suggestions:

(t11295)user@ubuntu:~/Workspace/t11295$ trac-admin tracdev repository resync "Trac"
20:06:59 Trac[PyGIT] ERROR: GIT control files missing in '/home/user/Workspace/t11295/teo-rjollos.git/'
20:06:59 Trac[PyGIT] ERROR: entry '.git' found in '/home/user/Workspace/t11295/teo-rjollos.git/' -- maybe use that folder instead...
20:06:59 Trac[git_fs] ERROR: GitError: GIT control files not found, maybe wrong directory?
TracError: /home/user/Workspace/t11295/teo-rjollos.git/ does not appear to be a Git repository.

The path must point to the .git directory: /home/user/Workspace/t11295/teo-rjollos.git/.git. However, this might be confusing to someone that has worked with Trac and SVN, since we point Directory to the root of the SVN repository.

I can think of two different approaches that might improve on this:

  1. Show ERROR: entry '.git' found in … message through the web interface when saving the repository configuration.
  2. Just append .git to the path if needed rather than showing an error.

In the future I was hoping we could add a Resync button to the web interface, so while the suggestions in this ticket wouldn't be an enormous improvement in usability since the user has to move to the command line to do the resync, it would have greater benefit when/if all the operations could be done though the web interface.

Attachments (0)

Change History (10)

comment:1 by Ryan J Ollos, 11 years ago

The other point of confusion could be bare vs non-bare repositories. If the repository directory is a bare repository, then you point it directly at the repository directory. In my example this would be /home/user/Workspace/t11295/teo-rjollos.git/, and the convention seems to have the name of a bare repository end with .git. If we had a non-bare repository though, the conventional name would be teo-rjollos and we would need to point the path to /home/user/Workspace/t11295/teo-rjollos/.git. Having the code append .git to the path for a non-bare repository when necessary still seems like the more user-friendly solution, and not much more complex than checking if the .git directory exists and issuing a warning.

in reply to:  description comment:2 by Jun Omae, 11 years ago

  1. Just append .git to the path if needed rather than showing an error.

+1

pygit2 library allows both bare repository and non-bare repository, http://www.pygit2.org/repository.html#the-repository-class.

>>> pygit2.__version__
'0.19.1'
>>> repos = pygit2.Repository('/notfound')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: '/notfound'
>>> repos = pygit2.Repository('/home/jun66j5/src/trac.git')
>>> repos.workdir
'/home/jun66j5/src/trac.git/'
>>> repos.head.target.hex
'b10a460091fe7d337081a7d84b78ff93696d639a'
>>> repos = pygit2.Repository('/home/jun66j5/src/trac.git/.git')
>>> repos.workdir
'/home/jun66j5/src/trac.git/'
>>> repos.head.target.hex
'b10a460091fe7d337081a7d84b78ff93696d639a'

comment:3 by Ryan J Ollos, 11 years ago

Milestone: 1.0.2
Owner: set to Ryan J Ollos
Status: newassigned
Version: 1.0-stable

Proposed changes can be found in log:rjollos.git:t11297.

comment:4 by Thijs Triemstra, 11 years ago

This might be a separate issue but I also noticed a single space being appended to the git path when first saving/adding it.

in reply to:  4 comment:5 by Ryan J Ollos, 11 years ago

Replying to thijstriemstra:

This might be a separate issue but I also noticed a single space being appended to the git path when first saving/adding it.

I haven't seen that issue. It sounds like it needs a dedicated ticket and more details on how to reproduce.

comment:6 by Ryan J Ollos, 11 years ago

Unrelated issue, the following test repeatedly failed for me this evening

======================================================================
FAIL: runTest (__main__.TestAdminMilestoneCompletedFuture)
Admin milestone completed in the future
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/Workspace/temp/teo-rjollos.git/trac/ticket/tests/functional.py", line 739, in runTest
    tc.find('Completion date may not be in the future')
  File "trac/tests/functional/better_twill.py", line 217, in better_find
    raise twill.errors.TwillAssertionError(*args)
TwillAssertionError: ("no match to 'Completion date may not be in the future'", '/home/user/Workspace/temp/teo-rjollos.git/testenv/trac/log/TestAdminMilestoneCompletedFuture.html')

----------------------------------------------------------------------
Ran 1 test in 3.401s

FAILED (failures=1)

The issue seems to be caused by daylight savings time happening this evening,

>>> format_datetime(datetime.now(utc))
u'11/03/13 00:29:44'
>>> format_datetime(datetime.now(utc) + timedelta(hours=1))
u'11/03/13 01:29:48'
>>> format_datetime(datetime.now(utc) + timedelta(hours=2))
u'11/03/13 01:29:50'
>>> format_datetime(datetime.now(utc) + timedelta(hours=24))
u'11/03/13 23:29:56'

Enough time has passed now that I'm not seeing the issue, and it would be rarely encountered, but we could avoid it with the following change:

  • trac/ticket/tests/functional.py

    diff --git a/trac/ticket/tests/functional.py b/trac/ticket/tests/functional.py
    index 30407b1..1a96659 100755
    a b class TestAdminMilestoneCompletedFuture(FunctionalTwillTestC  
    728728        tc.follow(name)
    729729        tc.url(milestone_url + '/' + name)
    730730        tc.formvalue('modifymilestone', 'completed', True)
    731         cdate = datetime.now(tz=utc) + timedelta(days=1)
     731        cdate = datetime.now(tz=utc) + timedelta(days=2)
    732732        cdate_string = format_date(cdate, tzinfo=localtz, locale=locale_en)
    733733        tc.formvalue('modifymilestone', 'completeddate', cdate_string)
    734734        tc.submit('save')

in reply to:  6 ; comment:7 by Jun Omae, 11 years ago

Enough time has passed now that I'm not seeing the issue, and it would be rarely encountered, but we could avoid it with the following change: …

Verified with libfaketime. It works well. Please commit!

$ TZ=America/Los_Angeles faketime '2013-11-03 00:29:00' date
Sun Nov  3 00:29:00 PDT 2013
$ TZ=America/Los_Angeles faketime '2013-11-03 00:29:00' date -d '2 hours'
Sun Nov  3 01:29:00 PST 2013
TZ=America/Los_Angeles PYTHONPATH=. faketime '2013-03-10 00:29:00' ~/venv/py26/bin/python trac/ticket/tests/functional.py -v
...
Admin milestone completed in the future ... ok
...
$ TZ=Europe/Berlin faketime '2013-10-27 00:30:00' date
Sun Oct 27 00:30:00 CEST 2013
$ TZ=Europe/Berlin faketime '2013-10-27 00:30:00' date -d '3 hours'
Sun Oct 27 02:30:00 CET 2013
$ TZ=Europe/Berlin PYTHONPATH=. faketime '2013-10-27 00:30:00' ~/venv/py26/bin/python trac/ticket/tests/functional.py -v
....
Admin milestone completed in the future ... ok
....

comment:8 by Ryan J Ollos, 11 years ago

Release Notes: modified (diff)

Change from log:rjollos.git:t11297 committed to 1.0-stable in [12225] and merged to trunk in [12226].

in reply to:  7 comment:9 by Ryan J Ollos, 11 years ago

Resolution: fixed
Status: assignedclosed

Replying to jomae:

Verified with libfaketime. It works well. Please commit!

Neat tool, thanks! Committed to 1.0-stable in [12227], and merged to trunk in [12228].

in reply to:  4 comment:10 by Ryan J Ollos, 11 years ago

Replying to thijstriemstra:

This might be a separate issue but I also noticed a single space being appended to the git path when first saving/adding it.

You may want to follow #11371.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.