Debian Codegraph @

python/mozversioncontrol/test/test_get_commits.py

raw
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 import mozunit
6
7 from mozversioncontrol import get_repository_object
8
9 STEPS = {
10 "hg": [
11 """
12 echo bar >> bar
13 hg commit -m "commit 1"
14 echo baz > baz
15 hg add baz
16 hg commit -m "commit 2"
17 """
18 ],
19 "git": [
20 """
21 echo bar >> bar
22 git add bar
23 git commit -m "commit 1"
24 echo baz > baz
25 git add baz
26 git commit -m "commit 2"
27 """
28 ],
29 "jj": [
30 """
31 jj new -m "commit 1"
32 echo bar >> bar
33 jj commit -m "commit 2"
34 echo baz > baz
35 jj log -n0 # snapshot, since mach's jj integration avoids doing this automatically
36 """
37 ],
38 }
39
40
41 def test_get_commits(repo):
42 vcs = get_repository_object(repo.dir)
43
44 # Create some commits
45 repo.execute_next_step()
46
47 # Get list of branch nodes.
48 nodes = vcs.get_commits()
49
50 assert len(nodes) == 2
51 assert all(len(node) == 40 for node in nodes), "Each node should be a 40-char SHA."
52
53
54 if __name__ == "__main__":
55 mozunit.main()