Commit fad15cf2 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add a tag test to pre_commit_run tests

parent 00dad587
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -135,13 +135,13 @@ def setup_fixture_repo(repo: Repo) -> None:
	The repository consists of three branches, two with common ancestors and one with no
	commonality with the other two:

	┌──────────────────────────────────┐
	┌──────────────────────────────────────────
"lca" (Last common ancestor)          │
	│           ↓                              │
	│   ○─○─○─○─○─○─○─○─○─● "main"    
	│   ○─○─○─○─○─○─○─○─○─● "main", tag:"test"
	│           └─○─○─○─○─● "fork"
	│   ○─○─○─○─○─○─○─○─○─● "orphan"
	└──────────────────────────────────┘
	└──────────────────────────────────────────
	"""
	random.seed(1)

@@ -157,6 +157,9 @@ def setup_fixture_repo(repo: Repo) -> None:
	orphan = Branch(repo, "orphan", create_commit(repo))
	orphan.head = create_commit_path(repo, orphan.root, 5)

	# Make test tag
	repo.command("tag", "test", main.head)


def create_commit_path(repo: Repo, source: Sha, number: int) -> Sha:
	"""
+9 −0
Original line number Diff line number Diff line
@@ -160,6 +160,15 @@ class PreCommitRunTests(unittest.TestCase):
		expect = ["run", "--all-files"]
		self.assertListEqual(expect, args)

	def test_tag(self) -> None:
		"""
		Check that pushing a tag works like pushing to a new branch
		"""
		args = self.run_script("refs/tags/test")

		expect = ["run", "--all-files"]
		self.assertListEqual(expect, args)

	def test_additional_arguments(self) -> None:
		"""
		Check additional arguments passed to pre_commit_run are passed to pre-commit