From: W. Trevor King Date: Sat, 28 Mar 2015 19:56:15 +0000 (-0700) Subject: project: Fallback to directory name if project/name isn't set X-Git-Tag: v0.6.2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=88d7ade9e272e079b457c449c931e04994b02429;p=update-copyright.git project: Fallback to directory name if project/name isn't set I recommend folks set this explicitly, but Greg Wilson wanted a way for folks to use update-copyright without having to tweak this name after forking [1]. The approach I've used here isn't the same as the one discussed in that issue (using the name of the upstream Git repository), but I think it's a better choice. Pros and cons: + Simple, VCS-agnostic implementation + Doesn't make assumptions about the upstream repository naming - Assumes folks name their local repository appropriately - Won't handle several projects stored in the same Git repository For example, if you have a branch for project-a and another for project-b that are both in your local project-a repository, you'll have to explicitly set project.name in the project-b branch's .update-copyright.conf. [1]: https://github.com/swcarpentry/lesson-template/pull/197#discussion_r26456407 --- diff --git a/README b/README index 7e85b80..a91e6bb 100644 --- a/README +++ b/README @@ -77,7 +77,8 @@ Options project/name A string naming your project. Replaces ``{project}`` in your - copyright blurbs. + copyright blurbs. If this isn't set, ``update-copyright`` will fall + back to using the name of the repository directory. project/vcs The name of your version control system. files/authors diff --git a/update_copyright/project.py b/update_copyright/project.py index 176ff68..0cb676c 100644 --- a/update_copyright/project.py +++ b/update_copyright/project.py @@ -71,7 +71,7 @@ class Project (object): project = parser['project'] except KeyError: project = {} - self._name = project.get('name') + self._name = project.get('name', _os_path.basename(self._root)) vcs = project.get('vcs') kwargs = { 'root': self._root,