| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -922,7 +922,8 @@ def move(self, items, skip_errors=False, **kwargs): | |||
| 922 | 922 | ||
| 923 | 923 | return out | |
| 924 | 924 | ||
| 925 | - def commit(self, message, parent_commits=None, head=True, author=None, committer=None): | ||
| 925 | + def commit(self, message, parent_commits=None, head=True, author=None, | ||
| 926 | + committer=None, author_date=None, commit_date=None): | ||
| 926 | 927 | """Commit the current default index file, creating a commit object. | |
| 927 | 928 | For more information on the arguments, see tree.commit. | |
| 928 | 929 | ||
@@ -932,7 +933,8 @@ def commit(self, message, parent_commits=None, head=True, author=None, committer | |||
| 932 | 933 | run_commit_hook('pre-commit', self) | |
| 933 | 934 | tree = self.write_tree() | |
| 934 | 935 | rval = Commit.create_from_tree(self.repo, tree, message, parent_commits, | |
| 935 | - head, author=author, committer=committer) | ||
| 936 | + head, author=author, committer=committer, | ||
| 937 | + author_date=author_date, commit_date=commit_date) | ||
| 936 | 938 | run_commit_hook('post-commit', self) | |
| 937 | 939 | return rval | |
| 938 | 940 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -266,7 +266,8 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream): | |||
| 266 | 266 | finalize_process(proc_or_stream) | |
| 267 | 267 | ||
| 268 | 268 | @classmethod | |
| 269 | - def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None): | ||
| 269 | + def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None, | ||
| 270 | + author_date=None, commit_date=None): | ||
| 270 | 271 | """Commit the given tree, creating a commit object. | |
| 271 | 272 | ||
| 272 | 273 | :param repo: Repo object the commit should be part of | |
@@ -288,6 +289,8 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, | |||
| 288 | 289 | configuration is used to obtain this value. | |
| 289 | 290 | :param committer: The name of the committer, optional. If unset, the | |
| 290 | 291 | repository configuration is used to obtain this value. | |
| 292 | + :param author_date: The timestamp for the author field | ||
| 293 | + :param commit_date: The timestamp for the committer field | ||
| 291 | 294 | ||
| 292 | 295 | :return: Commit object representing the new commit | |
| 293 | 296 | ||
@@ -327,14 +330,18 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, | |||
| 327 | 330 | offset = altzone | |
| 328 | 331 | ||
| 329 | 332 | author_date_str = env.get(cls.env_author_date, '') | |
| 330 | - if author_date_str: | ||
| 333 | + if author_date: | ||
| 334 | + author_time, author_offset = parse_date(author_date) | ||
| 335 | + elif author_date_str: | ||
| 331 | 336 | author_time, author_offset = parse_date(author_date_str) | |
| 332 | 337 | else: | |
| 333 | 338 | author_time, author_offset = unix_time, offset | |
| 334 | 339 | # END set author time | |
| 335 | 340 | ||
| 336 | 341 | committer_date_str = env.get(cls.env_committer_date, '') | |
| 337 | - if committer_date_str: | ||
| 342 | + if commit_date: | ||
| 343 | + committer_time, committer_offset = parse_date(commit_date) | ||
| 344 | + elif committer_date_str: | ||
| 338 | 345 | committer_time, committer_offset = parse_date(committer_date_str) | |
| 339 | 346 | else: | |
| 340 | 347 | committer_time, committer_offset = unix_time, offset | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -470,6 +470,17 @@ def mixed_iterator(): | |||
| 470 | 470 | assert cur_head.commit == commit_actor | |
| 471 | 471 | assert cur_head.log()[-1].actor == my_committer | |
| 472 | 472 | ||
| 473 | + # commit with author_date and commit_date | ||
| 474 | + cur_commit = cur_head.commit | ||
| 475 | + commit_message = u"commit with dates by Avinash Sajjanshetty" | ||
| 476 | + | ||
| 477 | + new_commit = index.commit(commit_message, author_date="2006-04-07T22:13:13", commit_date="2005-04-07T22:13:13") | ||
| 478 | + assert cur_commit != new_commit | ||
| 479 | + print(new_commit.authored_date, new_commit.committed_date) | ||
| 480 | + assert new_commit.message == commit_message | ||
| 481 | + assert new_commit.authored_date == 1144447993 | ||
| 482 | + assert new_commit.committed_date == 1112911993 | ||
| 483 | + | ||
| 473 | 484 | # same index, no parents | |
| 474 | 485 | commit_message = "index without parents" | |
| 475 | 486 | commit_no_parents = index.commit(commit_message, parent_commits=list(), head=True) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments