From 2057c23e53f033a4994eecfa004541f73f163e46 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karl=20Hasselstr=C3=B6m?= Date: Mon, 28 Jan 2008 23:11:32 +0100 Subject: [PATCH] Teach new infrastructure about the default author and committer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As specified by the config options user.name and user.email, and the environment variables GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL,DATE} (the latter overriding the former). Nothing uses this yet, but "stg edit" will soon. Signed-off-by: Karl Hasselström --- stgit/lib/git.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/stgit/lib/git.py b/stgit/lib/git.py index 6cd7450..2ca4495 100644 --- a/stgit/lib/git.py +++ b/stgit/lib/git.py @@ -1,5 +1,6 @@ import os, os.path, re from stgit import exception, run, utils +from stgit.config import config class RepositoryException(exception.StgException): pass @@ -52,6 +53,30 @@ class Person(Repr): email = m.group(2) date = m.group(3) return cls(name, email, date) + @classmethod + def user(cls): + if not hasattr(cls, '__user'): + cls.__user = cls(name = config.get('user.name'), + email = config.get('user.email')) + return cls.__user + @classmethod + def author(cls): + if not hasattr(cls, '__author'): + cls.__author = cls( + name = os.environ.get('GIT_AUTHOR_NAME', NoValue), + email = os.environ.get('GIT_AUTHOR_EMAIL', NoValue), + date = os.environ.get('GIT_AUTHOR_DATE', NoValue), + defaults = cls.user()) + return cls.__author + @classmethod + def committer(cls): + if not hasattr(cls, '__committer'): + cls.__committer = cls( + name = os.environ.get('GIT_COMMITTER_NAME', NoValue), + email = os.environ.get('GIT_COMMITTER_EMAIL', NoValue), + date = os.environ.get('GIT_COMMITTER_DATE', NoValue), + defaults = cls.user()) + return cls.__committer class Tree(Repr): """Immutable.""" -- 2.11.0