diff options
-rw-r--r-- | project.py | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -1969,7 +1969,9 @@ class Project(object): | |||
1969 | 1969 | ||
1970 | Since we don't have a 'rev_parse' method defined, the __getattr__ will | 1970 | Since we don't have a 'rev_parse' method defined, the __getattr__ will |
1971 | run. We'll replace the '_' with a '-' and try to run a git command. | 1971 | run. We'll replace the '_' with a '-' and try to run a git command. |
1972 | Any other arguments will be passed to the git command. | 1972 | Any other positional arguments will be passed to the git command, and the |
1973 | following keyword arguments are supported: | ||
1974 | config: An optional dict of git config options to be passed with '-c'. | ||
1973 | 1975 | ||
1974 | Args: | 1976 | Args: |
1975 | name: The name of the git command to call. Any '_' characters will | 1977 | name: The name of the git command to call. Any '_' characters will |
@@ -1979,8 +1981,17 @@ class Project(object): | |||
1979 | A callable object that will try to call git with the named command. | 1981 | A callable object that will try to call git with the named command. |
1980 | """ | 1982 | """ |
1981 | name = name.replace('_', '-') | 1983 | name = name.replace('_', '-') |
1982 | def runner(*args): | 1984 | def runner(*args, **kwargs): |
1983 | cmdv = [name] | 1985 | cmdv = [] |
1986 | config = kwargs.pop('config', None) | ||
1987 | for k in kwargs: | ||
1988 | raise TypeError('%s() got an unexpected keyword argument %r' | ||
1989 | % (name, k)) | ||
1990 | if config is not None: | ||
1991 | for k, v in config.iteritems(): | ||
1992 | cmdv.append('-c') | ||
1993 | cmdv.append('%s=%s' % (k, v)) | ||
1994 | cmdv.append(name) | ||
1984 | cmdv.extend(args) | 1995 | cmdv.extend(args) |
1985 | p = GitCommand(self._project, | 1996 | p = GitCommand(self._project, |
1986 | cmdv, | 1997 | cmdv, |