| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -867,7 +867,7 @@ def move(self, items, skip_errors=False, **kwargs): | |||
| 867 | 867 | ||
| 868 | 868 | return out | |
| 869 | 869 | ||
| 870 | - def commit(self, message, parent_commits=None, head=True): | ||
| 870 | + def commit(self, message, parent_commits=None, head=True, author=None, committer=None): | ||
| 871 | 871 | """Commit the current default index file, creating a commit object. | |
| 872 | 872 | ||
| 873 | 873 | For more information on the arguments, see tree.commit. | |
@@ -878,7 +878,7 @@ def commit(self, message, parent_commits=None, head=True): | |||
| 878 | 878 | :return: | |
| 879 | 879 | Commit object representing the new commit""" | |
| 880 | 880 | tree = self.write_tree() | |
| 881 | - return Commit.create_from_tree(self.repo, tree, message, parent_commits, head) | ||
| 881 | + return Commit.create_from_tree(self.repo, tree, message, parent_commits, head, author=author, committer=committer) | ||
| 882 | 882 | ||
| 883 | 883 | @classmethod | |
| 884 | 884 | def _flush_stdin_and_wait(cls, proc, ignore_stdout=False): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -258,7 +258,7 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream): | |||
| 258 | 258 | finalize_process(proc_or_stream) | |
| 259 | 259 | ||
| 260 | 260 | @classmethod | |
| 261 | - def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False): | ||
| 261 | + def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None): | ||
| 262 | 262 | """Commit the given tree, creating a commit object. | |
| 263 | 263 | ||
| 264 | 264 | :param repo: Repo object the commit should be part of | |
@@ -303,8 +303,8 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False): | |||
| 303 | 303 | cr = repo.config_reader() | |
| 304 | 304 | env = os.environ | |
| 305 | 305 | ||
| 306 | - committer = Actor.committer(cr) | ||
| 307 | - author = Actor.author(cr) | ||
| 306 | + committer = committer or Actor.committer(cr) | ||
| 307 | + author = author or Actor.author(cr) | ||
| 308 | 308 | ||
| 309 | 309 | # PARSE THE DATES | |
| 310 | 310 | unix_time = int(time()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -235,7 +235,8 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message): | |||
| 235 | 235 | """Append a new log entry to the revlog at filepath. | |
| 236 | 236 | ||
| 237 | 237 | :param config_reader: configuration reader of the repository - used to obtain | |
| 238 | - user information. May be None | ||
| 238 | + user information. May also be an Actor instance identifying the committer directly. | ||
| 239 | + May also be None | ||
| 239 | 240 | :param filepath: full path to the log file | |
| 240 | 241 | :param oldbinsha: binary sha of the previous commit | |
| 241 | 242 | :param newbinsha: binary sha of the current commit | |
@@ -249,8 +250,9 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message): | |||
| 249 | 250 | raise ValueError("Shas need to be given in binary format") | |
| 250 | 251 | #END handle sha type | |
| 251 | 252 | assure_directory_exists(filepath, is_file=True) | |
| 252 | - entry = RefLogEntry((bin_to_hex(oldbinsha), bin_to_hex(newbinsha), Actor.committer(config_reader), (int(time.time()), time.altzone), message)) | ||
| 253 | - | ||
| 253 | + committer = isinstance(config_reader, Actor) and config_reader or Actor.committer(config_reader) | ||
| 254 | + entry = RefLogEntry((bin_to_hex(oldbinsha), bin_to_hex(newbinsha), committer, (int(time.time()), time.altzone), message)) | ||
| 255 | + | ||
| 254 | 256 | lf = LockFile(filepath) | |
| 255 | 257 | lf._obtain_lock_or_raise() | |
| 256 | 258 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -355,9 +355,11 @@ def log_append(self, oldbinsha, message, newbinsha=None): | |||
| 355 | 355 | :param newbinsha: The sha the ref points to now. If None, our current commit sha | |
| 356 | 356 | will be used | |
| 357 | 357 | :return: added RefLogEntry instance""" | |
| 358 | - return RefLog.append_entry(self.repo.config_reader(), RefLog.path(self), oldbinsha, | ||
| 359 | - (newbinsha is None and self.commit.binsha) or newbinsha, | ||
| 360 | - message) | ||
| 358 | + # NOTE: we use the committer of the currently active commit - this should be | ||
| 359 | + # correct. See https://github.com/gitpython-developers/GitPython/pull/146 | ||
| 360 | + return RefLog.append_entry(self.commit.committer, RefLog.path(self), oldbinsha, | ||
| 361 | + (newbinsha is None and self.commit.binsha) or newbinsha, | ||
| 362 | + message) | ||
| 361 | 363 | ||
| 362 | 364 | def log_entry(self, index): | |
| 363 | 365 | """:return: RefLogEntry at the given index | |
| Back | FazBrowse Home | New Git URL |
0 commit comments