def test_fake_dates(path): gr = GitRepo(path, create=True, fake_dates=True) gr.add("foo") gr.commit("commit foo") seconds_initial = gr.config.obtain("datalad.fake-dates-start") # First commit is incremented by 1 second. eq_(seconds_initial + 1, gr.get_commit_date()) # The second commit by 2. gr.add("bar") gr.commit("commit bar") eq_(seconds_initial + 2, gr.get_commit_date()) # If we checkout another branch, its time is still based on the latest # timestamp in any local branch. gr.checkout("other", options=["--orphan"]) with open(op.join(path, "baz"), "w") as ofh: ofh.write("baz content") gr.add("baz") gr.commit("commit baz") eq_(gr.get_active_branch(), "other") eq_(seconds_initial + 3, gr.get_commit_date())
def test_fake_dates(path): gr = GitRepo(path, create=True, fake_dates=True) gr.add("foo") gr.commit("commit foo") seconds_initial = gr.config.obtain("datalad.fake-dates-start") # First commit is incremented by 1 second. eq_(seconds_initial + 1, gr.get_commit_date()) # The second commit by 2. gr.add("bar") gr.commit("commit bar") eq_(seconds_initial + 2, gr.get_commit_date()) # If we checkout another branch, its time is still based on the latest # timestamp in any local branch. gr.checkout("other", options=["--orphan"]) with open(op.join(path, "baz"), "w") as ofh: ofh.write("baz content") gr.add("baz") gr.commit("commit baz") eq_(gr.get_active_branch(), "other") eq_(seconds_initial + 3, gr.get_commit_date())
def test_get_commit_date(path): gr = GitRepo(path, create=True) eq_(gr.get_commit_date(), None) # Let's make a commit with a custom date DATE = "Wed Mar 14 03:47:30 2018 -0000" DATE_EPOCH = 1520999250 gr.add('1') gr.commit("committed", date=DATE) gr = GitRepo(path, create=True) date = gr.get_commit_date() neq_(date, None) eq_(date, DATE_EPOCH) eq_(date, gr.get_commit_date('master')) # and even if we get into a detached head gr.checkout(gr.get_hexsha()) eq_(gr.get_active_branch(), None) eq_(date, gr.get_commit_date('master'))
def test_get_commit_date(path): gr = GitRepo(path, create=True) eq_(gr.get_commit_date(), None) # Let's make a commit with a custom date DATE = "Wed Mar 14 03:47:30 2018 -0000" DATE_EPOCH = 1520999250 gr.add('1') gr.commit("committed", date=DATE) gr = GitRepo(path, create=True) date = gr.get_commit_date() neq_(date, None) eq_(date, DATE_EPOCH) eq_(date, gr.get_commit_date('master')) # and even if we get into a detached head gr.checkout(gr.get_hexsha()) eq_(gr.get_active_branch(), None) eq_(date, gr.get_commit_date('master'))