_get_this_repo fails if user is not in top level of git repo

Bug #1922038 reported by Robert C Jennings
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad tooling for Git
Fix Released
High
Robert C Jennings

Bug Description

When git lp-propose is run from a sub directory below the root of the repo we get a traceback. As a user I can ask git to find the root of the tree using 'git rev-parse --show-toplevel'. And for your initialization of git.Repo(... you can pass 'search_parent_directories=True' to resolve this.

$ git clone https://git.launchpad.net/gitlptools
$ cd gitlptools/src/gitlptools
$ git lp-propose ....
Traceback (most recent call last):
  File "/snap/gitlptools/37/bin/git-lp-propose", line 11, in <module>
    load_entry_point('gitlptools==1.0', 'console_scripts', 'git-lp-propose')()
  File "/snap/gitlptools/37/lib/python3.6/site-packages/gitlptools/__init__.py", line 210, in git_lp_propose
    options = parse_args_with_logging(parser, argv)
  File "/snap/gitlptools/37/lib/python3.6/site-packages/gitlptools/__init__.py", line 411, in parse_args_with_logging
    options = parser.parse_args(argv)
  File "/snap/gitlptools/37/usr/lib/python3.6/argparse.py", line 1743, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/snap/gitlptools/37/usr/lib/python3.6/argparse.py", line 1775, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/snap/gitlptools/37/usr/lib/python3.6/argparse.py", line 1984, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "/snap/gitlptools/37/usr/lib/python3.6/argparse.py", line 1940, in consume_positionals
    take_action(action, args)
  File "/snap/gitlptools/37/usr/lib/python3.6/argparse.py", line 1849, in take_action
    action(self, namespace, argument_values, option_string)
  File "/snap/gitlptools/37/lib/python3.6/site-packages/gitlptools/__init__.py", line 50, in __call__
    merge_target = get_merge_target(_get_this_repo(), values)
  File "/snap/gitlptools/37/lib/python3.6/site-packages/gitlptools/__init__.py", line 393, in _get_this_repo
    return git.Repo(repo_path)
  File "/snap/gitlptools/37/lib/python3.6/site-packages/git/repo/base.py", line 181, in __init__
    raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: /home/fake/gitlptools/src/gitlptools

Related branches

Changed in gitlptools:
status: New → In Progress
importance: Undecided → High
assignee: nobody → Robert C Jennings (rcj)
Changed in gitlptools:
status: In Progress → Fix Committed
status: Fix Committed → Won't Fix
status: Won't Fix → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.