|
1 | 1 | import functools |
| 2 | +import json |
2 | 3 | import os |
3 | 4 | import site |
4 | 5 | import stat |
@@ -179,6 +180,17 @@ def test_install_pip_requirements_with_uv( |
179 | 180 | {"shallow-clone": True}, |
180 | 181 | id="git_with_shallow_clone", |
181 | 182 | ), |
| 183 | + pytest.param( |
| 184 | + {}, |
| 185 | + { |
| 186 | + "REPOSITORY_TYPE": "git", |
| 187 | + "HEAD_REPOSITORY": "https://github.com/example/repo", |
| 188 | + "HEAD_REV": "abc123", |
| 189 | + "EXTRA_REFS": json.dumps(["refs/notes/taskgraph", "refs/notes/other"]), |
| 190 | + }, |
| 191 | + {"extra-refs": ["refs/notes/taskgraph", "refs/notes/other"]}, |
| 192 | + id="git_with_extra_refs", |
| 193 | + ), |
182 | 194 | ], |
183 | 195 | ) |
184 | 196 | def test_collect_vcs_options( |
@@ -216,6 +228,7 @@ def test_collect_vcs_options( |
216 | 228 | "shallow-clone": False, |
217 | 229 | "ssh-secret-name": env.get("SSH_SECRET_NAME"), |
218 | 230 | "store-path": env.get("HG_STORE_PATH"), |
| 231 | + "extra-refs": None, |
219 | 232 | } |
220 | 233 | if "PIP_REQUIREMENTS" in env: |
221 | 234 | expected["pip-requirements"] = os.path.join( |
@@ -638,3 +651,36 @@ def test_main_abspath_environment(mocker, run_main): |
638 | 651 | assert env.get("MOZ_UV_HOME") == "/builds/worker/dir/uv" |
639 | 652 | for key in envvars: |
640 | 653 | assert env[key] == "/builds/worker/file" |
| 654 | + |
| 655 | + |
| 656 | +def test_git_checkout_extra_refs(mock_stdin, run_task_mod, mock_git_repo, tmp_path): |
| 657 | + """extra_refs are fetched into the local repo during checkout.""" |
| 658 | + # Add a notes ref to the source repo |
| 659 | + rev = mock_git_repo["main"][-1] |
| 660 | + subprocess.check_call( |
| 661 | + ["git", "notes", "--ref=refs/notes/taskgraph", "add", "-m", "test", rev], |
| 662 | + cwd=mock_git_repo["path"], |
| 663 | + ) |
| 664 | + |
| 665 | + destination = tmp_path / "destination" |
| 666 | + run_task_mod.git_checkout( |
| 667 | + destination_path=str(destination), |
| 668 | + head_repo=mock_git_repo["path"], |
| 669 | + base_repo=mock_git_repo["path"], |
| 670 | + base_rev=None, |
| 671 | + head_ref="main", |
| 672 | + head_rev=None, |
| 673 | + ssh_key_file=None, |
| 674 | + ssh_known_hosts_file=None, |
| 675 | + extra_refs=["refs/notes/taskgraph"], |
| 676 | + ) |
| 677 | + |
| 678 | + # Verify the notes ref is available locally |
| 679 | + result = subprocess.run( |
| 680 | + ["git", "notes", "--ref=refs/notes/taskgraph", "show", rev], |
| 681 | + cwd=str(destination), |
| 682 | + capture_output=True, |
| 683 | + text=True, |
| 684 | + ) |
| 685 | + assert result.returncode == 0 |
| 686 | + assert "test" in result.stdout |
0 commit comments