@@ -619,17 +619,22 @@ const guideline_src_names_OK = Guideline(;
619619)
620620
621621function meets_code_can_be_downloaded (registry_head, pkg, version, pr; pkg_code_path)
622- uuid, package_repo, subdir, tree_hash_from_toml = parse_registry_pkg_info (
622+ uuid, package_repo, subdir, tree_hash_from_toml, commit_hash_from_toml, tag_hash_from_toml, tag_name_from_toml = parse_registry_pkg_info (
623623 registry_head, pkg, version
624624 )
625625
626626 # We get the `tree_hash` two ways and check they agree, which helps ensures the `subdir` parameter is correct. Two ways:
627- # 1. By the commit hash in the PR body and the subdir parameter
627+ # 1. By the commit hash and the subdir parameter
628628 # 2. By the tree hash in the Versions.toml
629629
630- commit_hash = commit_from_pull_request_body (pr)
630+ if isnothing (commit_hash_from_toml)
631+ # git-commit-sha1 is an optional registry key: if it isn't in the .toml, then we query the PR
632+ commit_hash = commit_from_pull_request_body (pr)
633+ else
634+ commit_hash = commit_hash_from_toml
635+ end
631636
632- local tree_hash_from_commit, tree_hash_from_commit_success
637+ local tree_hash_from_commit, tree_hash_from_commit_success, tag_success
633638 clone_success = load_files_from_url_and_tree_hash (
634639 pkg_code_path, package_repo, tree_hash_from_toml
635640 ) do dir
@@ -639,6 +644,23 @@ function meets_code_can_be_downloaded(registry_head, pkg, version, pr; pkg_code_
639644 @error e
640645 " " , false
641646 end
647+
648+ tag_success = try
649+ if ! isnothing (tag_hash_from_toml)
650+ commit_hash_from_tag = readchomp (Cmd (` git rev-parse $(tag_hash_from_toml) ^\{ commit\} ` ; dir= dir))
651+ @assert commit_hash_from_tag == commit_hash_from_toml
652+ end
653+ if ! isnothing (tag_name_from_toml)
654+ hash_from_tag_name = readchomp (Cmd (` git rev-parse $(tag_name_from_toml) ` ; dir= dir))
655+ # if an annotated tag, should point to the tag object
656+ # if a lightweight tag, should point to the commit object
657+ @assert hash_from_tag_name == something (tag_hash_from_toml, commit_hash_from_toml)
658+ end
659+ true
660+ catch e
661+ @error e
662+ false
663+ end
642664 end
643665
644666 if ! clone_success
@@ -654,9 +676,13 @@ function meets_code_can_be_downloaded(registry_head, pkg, version, pr; pkg_code_
654676 @error " `tree_hash_from_commit != tree_hash_from_toml`" tree_hash_from_commit tree_hash_from_toml
655677 return false ,
656678 " Tree hash obtained from the commit message and subdirectory does not match the tree hash in the Versions.toml file. Possibly this indicates that an incorrect `subdir` parameter was passed during registration."
657- else
658- return true , " "
659679 end
680+
681+ if ! tag_success
682+ return false , " Tag information in .toml does not match information in repository"
683+ end
684+
685+ return true
660686end
661687
662688function _generate_pkg_add_command (pkg:: String , version:: VersionNumber ):: String
0 commit comments