#12896 closed defect (fixed)
GIT control files missing error is raised if directory of git repository is not readable
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.17 |
Component: | plugin/git | Version: | 1.0.15 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Improve validations of a git repository. |
||
API Changes: | |||
Internal Changes: |
Description
This behavior confuses a user and isn't helpful. I think we should raise Make sure the Git repository is readable error rather than the error.
In particular, we should use os.listdir()
before os.path.exists()
. os.path.exists()
with non-readable directory returns False
without any exception.
Attachments (0)
Change History (6)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
This looks good. See also #12797 (r15924).
Considering comment:4:ticket:12797 and the possible exceptions that lead to re-raising (path) does not appear to be a git repository, we might want to change the message:
-
tracopt/versioncontrol/git/PyGIT.py
diff --git a/tracopt/versioncontrol/git/PyGIT.py b/tracopt/versioncontrol/git/PyGIT.py index 26a52a28b..d1ce2d9af 100644
a b class Storage(object): 404 404 dot_git_dir = os.path.join(git_dir, '.git') 405 405 try: 406 406 os.listdir(dot_git_dir) 407 except EnvironmentError , e:407 except EnvironmentError: 408 408 missing = True 409 409 else: 410 410 if self._control_files_exist(dot_git_dir): -
tracopt/versioncontrol/git/git_fs.py
diff --git a/tracopt/versioncontrol/git/git_fs.py b/tracopt/versioncontrol/git/git_fs.py index 031f68c2b..c5eb64db5 100644
a b class GitRepository(Repository): 493 493 except PyGIT.GitError, e: 494 494 log.error(exception_to_unicode(e)) 495 495 raise InvalidRepository( 496 _( "%(path)s does not appear to be a Git repository.",497 path=path))496 _('"%(name)s" is not readable or not a Git repository.', 497 name=params.get('name') or '(default)')) 498 498 499 499 Repository.__init__(self, 'git:' + path, self.params, log) 500 500 self._cached_git_id = str(self.id)
comment:3 by , 7 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
That makes sense. Revised jomae.git@t12896 with your suggested changes and created jomae.git@t12896+1.2 and jomae.git@t12896+trunk.
comment:5 by , 7 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed in [16283] and merged in [16284-16285].
Proposed changes in [8610a12ce/jomae.git] (jomae.git@t12896).