-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_revlist.py
More file actions
23 lines (17 loc) · 932 Bytes
/
test_revlist.py
File metadata and controls
23 lines (17 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import subprocess
def test_revlist(repo_init_with_commit, commit_env_config, git2cpp_path, tmp_path):
assert (tmp_path / "initial.txt").exists()
p = tmp_path / "initial.txt"
p.write_text("commit2")
subprocess.run([git2cpp_path, "add", "initial.txt"], cwd=tmp_path, check=True)
subprocess.run([git2cpp_path, "commit", "-m", "commit 2"], cwd=tmp_path, check=True)
p.write_text("commit3")
subprocess.run([git2cpp_path, "add", "initial.txt"], cwd=tmp_path, check=True)
subprocess.run([git2cpp_path, "commit", "-m", "commit 3"], cwd=tmp_path, check=True)
cmd = [git2cpp_path, "rev-list", "HEAD", "--max-count", "2"]
p = subprocess.run(cmd, capture_output=True, cwd=tmp_path, text=True)
assert p.returncode == 0
lines = [line for line in p.stdout.splitlines() if line.strip()]
assert len(lines) == 2
assert all(len(oid) == 40 for oid in lines)
assert lines[0] != lines[1]