Show More
@@ -1,147 +1,141 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
|
5 | 4 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | 5 | # (only), as published by the Free Software Foundation. |
|
7 | 6 | # |
|
8 | 7 | # This program is distributed in the hope that it will be useful, |
|
9 | 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | 10 | # GNU General Public License for more details. |
|
12 | 11 | # |
|
13 | 12 | # You should have received a copy of the GNU Affero General Public License |
|
14 | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | 14 | # |
|
16 | 15 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | 16 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | 17 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | 18 | |
|
20 | 19 | import datetime |
|
21 | 20 | |
|
22 | 21 | import pytest |
|
23 | 22 | |
|
24 | 23 | from rhodecode.lib.vcs.nodes import FileNode |
|
25 | 24 | from rhodecode.tests.vcs.conftest import BackendTestMixin |
|
26 | 25 | |
|
27 | 26 | |
|
28 | 27 | @pytest.mark.usefixtures("vcs_repository_support") |
|
29 | 28 | class TestBranches(BackendTestMixin): |
|
30 | ||
|
31 | 29 | def test_empty_repository_has_no_branches(self, vcsbackend): |
|
32 | 30 | empty_repo = vcsbackend.create_repo() |
|
33 | 31 | assert empty_repo.branches == {} |
|
34 | 32 | |
|
35 | 33 | def test_branches_all(self, vcsbackend): |
|
36 | 34 | branch_count = { |
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
35 | "git": 1, | |
|
36 | "hg": 1, | |
|
37 | "svn": 0, | |
|
40 | 38 | } |
|
41 | 39 | assert len(self.repo.branches_all) == branch_count[vcsbackend.alias] |
|
42 | 40 | |
|
43 | 41 | def test_closed_branches(self): |
|
44 | 42 | assert len(self.repo.branches_closed) == 0 |
|
45 | 43 | |
|
46 | 44 | def test_simple(self, local_dt_to_utc): |
|
47 | 45 | tip = self.repo.get_commit() |
|
48 |
assert tip.message == |
|
|
46 | assert tip.message == "Changes..." | |
|
49 | 47 | assert tip.date == local_dt_to_utc(datetime.datetime(2010, 1, 1, 21)) |
|
50 | 48 | |
|
51 | 49 | @pytest.mark.backends("git", "hg") |
|
52 | 50 | def test_new_branch(self): |
|
53 | 51 | # This check must not be removed to ensure the 'branches' LazyProperty |
|
54 | 52 | # gets hit *before* the new 'foobar' branch got created: |
|
55 |
assert |
|
|
56 | self.imc.add( | |
|
57 | FileNode(b'docs/index.txt', content=b'Documentation\n') | |
|
58 | ) | |
|
53 | assert "foobar" not in self.repo.branches | |
|
54 | self.imc.add(FileNode(b"docs/index.txt", content=b"Documentation\n")) | |
|
59 | 55 | foobar_tip = self.imc.commit( |
|
60 |
message= |
|
|
61 |
author= |
|
|
62 |
branch= |
|
|
56 | message="New branch: foobar", | |
|
57 | author="joe <joe@rhodecode.com>", | |
|
58 | branch="foobar", | |
|
63 | 59 | ) |
|
64 |
assert |
|
|
65 |
assert foobar_tip.branch == |
|
|
60 | assert "foobar" in self.repo.branches | |
|
61 | assert foobar_tip.branch == "foobar" | |
|
66 | 62 | |
|
67 | 63 | @pytest.mark.backends("git", "hg") |
|
68 | 64 | def test_new_head(self): |
|
69 | 65 | tip = self.repo.get_commit() |
|
66 | ||
|
70 | 67 | self.imc.add( |
|
71 |
FileNode(b |
|
|
72 | content=b'Documentation\n') | |
|
68 | FileNode(b"docs/index.txt", content=b"Documentation\n") | |
|
73 | 69 | ) |
|
74 | 70 | foobar_tip = self.imc.commit( |
|
75 |
message= |
|
|
76 |
author= |
|
|
77 |
branch= |
|
|
71 | message="New branch: foobar", | |
|
72 | author="joe <joe@rhodecode.com>", | |
|
73 | branch="foobar", | |
|
78 | 74 | parents=[tip], |
|
79 | 75 | ) |
|
80 |
self.imc.change( |
|
|
81 | b'docs/index.txt', | |
|
82 | content=b'Documentation\nand more...\n')) | |
|
76 | self.imc.change( | |
|
77 | FileNode(b"docs/index.txt", content=b"Documentation\nand more...\n") | |
|
78 | ) | |
|
79 | assert foobar_tip.branch == "foobar" | |
|
83 | 80 | newtip = self.imc.commit( |
|
84 |
message= |
|
|
85 |
author= |
|
|
81 | message="At foobar_tip branch", | |
|
82 | author="joe <joe@rhodecode.com>", | |
|
86 | 83 | branch=foobar_tip.branch, |
|
87 | 84 | parents=[foobar_tip], |
|
88 | 85 | ) |
|
89 | 86 | |
|
90 | 87 | newest_tip = self.imc.commit( |
|
91 |
message= |
|
|
92 |
author= |
|
|
88 | message=f"Merged with {foobar_tip.raw_id}", | |
|
89 | author="joe <joe@rhodecode.com>", | |
|
93 | 90 | branch=self.backend_class.DEFAULT_BRANCH_NAME, |
|
94 |
parents=[ |
|
|
91 | parents=[tip, newtip], | |
|
95 | 92 | ) |
|
96 | 93 | |
|
97 |
assert newest_tip.branch == |
|
|
98 | self.backend_class.DEFAULT_BRANCH_NAME | |
|
94 | assert newest_tip.branch == self.backend_class.DEFAULT_BRANCH_NAME | |
|
99 | 95 | |
|
100 | 96 | @pytest.mark.backends("git", "hg") |
|
101 | 97 | def test_branch_with_slash_in_name(self): |
|
102 |
self.imc.add(FileNode(b |
|
|
98 | self.imc.add(FileNode(b"extrafile", content=b"Some data\n")) | |
|
103 | 99 | self.imc.commit( |
|
104 |
|
|
|
105 | branch='issue/123') | |
|
106 |
assert |
|
|
100 | "Branch with a slash!", author="joe <joe@rhodecode.com>", branch="issue/123" | |
|
101 | ) | |
|
102 | assert "issue/123" in self.repo.branches | |
|
107 | 103 | |
|
108 | 104 | @pytest.mark.backends("git", "hg") |
|
109 | 105 | def test_branch_with_slash_in_name_and_similar_without(self): |
|
110 |
self.imc.add(FileNode(b |
|
|
106 | self.imc.add(FileNode(b"extrafile", content=b"Some data\n")) | |
|
111 | 107 | self.imc.commit( |
|
112 |
|
|
|
113 | branch='issue/123') | |
|
114 |
self.imc.add(FileNode(b |
|
|
108 | "Branch with a slash!", author="joe <joe@rhodecode.com>", branch="issue/123" | |
|
109 | ) | |
|
110 | self.imc.add(FileNode(b"extrafile II", content=b"Some data\n")) | |
|
115 | 111 | self.imc.commit( |
|
116 |
|
|
|
117 | branch='123') | |
|
118 |
assert |
|
|
119 |
assert |
|
|
112 | "Branch without a slash...", author="joe <joe@rhodecode.com>", branch="123" | |
|
113 | ) | |
|
114 | assert "issue/123" in self.repo.branches | |
|
115 | assert "123" in self.repo.branches | |
|
120 | 116 | |
|
121 | 117 | |
|
122 | 118 | class TestSvnBranches(object): |
|
123 | ||
|
124 | 119 | def test_empty_repository_has_no_tags_and_branches(self, vcsbackend_svn): |
|
125 | 120 | empty_repo = vcsbackend_svn.create_repo() |
|
126 | 121 | assert empty_repo.branches == {} |
|
127 | 122 | assert empty_repo.tags == {} |
|
128 | 123 | |
|
129 | 124 | def test_missing_structure_has_no_tags_and_branches(self, vcsbackend_svn): |
|
130 | 125 | repo = vcsbackend_svn.create_repo(number_of_commits=1) |
|
131 | 126 | assert repo.branches == {} |
|
132 | 127 | assert repo.tags == {} |
|
133 | 128 | |
|
134 | 129 | def test_discovers_ordered_branches(self, vcsbackend_svn): |
|
135 |
repo = vcsbackend_svn[ |
|
|
130 | repo = vcsbackend_svn["svn-simple-layout"] | |
|
136 | 131 | expected_branches = [ |
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
132 | "branches/add-docs", | |
|
133 | "branches/argparse", | |
|
134 | "trunk", | |
|
140 | 135 | ] |
|
141 | 136 | assert list(repo.branches.keys()) == expected_branches |
|
142 | 137 | |
|
143 | 138 | def test_discovers_ordered_tags(self, vcsbackend_svn): |
|
144 |
repo = vcsbackend_svn[ |
|
|
145 | expected_tags = [ | |
|
146 | 'tags/v0.1', 'tags/v0.2', 'tags/v0.3', 'tags/v0.5'] | |
|
139 | repo = vcsbackend_svn["svn-simple-layout"] | |
|
140 | expected_tags = ["tags/v0.1", "tags/v0.2", "tags/v0.3", "tags/v0.5"] | |
|
147 | 141 | assert list(repo.tags.keys()) == expected_tags |
General Comments 0
You need to be logged in to leave comments.
Login now