From 7a3056f17312a25102aa794b530a1a1ab148aced Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 28 Mar 2015 12:52:03 -0700 Subject: [PATCH] project: Require project/vcs We use the configured VCS for the author list and per-file updates, so there's nothing we can do if the user hasn't set it. Instead of crashing with: Traceback (most recent call last): File "./bin/update-copyright.py", line 80, in project.update_authors(dry_run=args.dry_run) File "/.../update_copyright/project.py", line 162, in update_authors authors = self._vcs.authors() AttributeError: 'NoneType' object has no attribute 'authors' Die earlier with: Traceback (most recent call last): File "./bin/update-copyright.py", line 78, in project.load_config(open(args.config, 'r')) File "/home/wking/src/update-copyright/update_copyright/project.py", line 66, in load_config loader(parser=parser) File "/home/wking/src/update-copyright/update_copyright/project.py", line 89, in _load_project_conf raise NotImplementedError('vcs: {}'.format(vcs)) NotImplementedError: vcs: None We may want to add some auto-detection logic here in the future. --- update_copyright/project.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/update_copyright/project.py b/update_copyright/project.py index e04364f..176ff68 100644 --- a/update_copyright/project.py +++ b/update_copyright/project.py @@ -73,21 +73,20 @@ class Project (object): project = {} self._name = project.get('name') vcs = project.get('vcs') - if vcs: - kwargs = { - 'root': self._root, - 'author_hacks': self._author_hacks, - 'year_hacks': self._year_hacks, - 'aliases': self._aliases, - } - if vcs == 'Git': - self._vcs = _GitBackend(**kwargs) - elif vcs == 'Mercurial': - if _MercurialBackend is None: - raise _mercurial_import_error - self._vcs = _MercurialBackend(**kwargs) - else: - raise NotImplementedError('vcs: {}'.format(vcs)) + kwargs = { + 'root': self._root, + 'author_hacks': self._author_hacks, + 'year_hacks': self._year_hacks, + 'aliases': self._aliases, + } + if vcs == 'Git': + self._vcs = _GitBackend(**kwargs) + elif vcs == 'Mercurial': + if _MercurialBackend is None: + raise _mercurial_import_error + self._vcs = _MercurialBackend(**kwargs) + else: + raise NotImplementedError('vcs: {}'.format(vcs)) def _load_copyright_conf(self, parser): try: -- 2.26.2