RegistryCI.jl icon indicating copy to clipboard operation
RegistryCI.jl copied to clipboard

TagBot: fixup PR creation fails with invalid base

Open christopher-dG opened this issue 4 years ago • 3 comments

https://github.com/JuliaRegistries/General/runs/1513863303?check_suite_focus=true

I'm guessing fork.default_branch is null but I haven't been able to reproduce.

christopher-dG avatar Dec 08 '20 15:12 christopher-dG

In this case, I wonder if the fix is:

  1. Delete the fork
  2. Re-fork the repo

DilumAluthge avatar Dec 12 '20 05:12 DilumAluthge

Also, if the issue is that we don't know what the default branch is, we can always just use this:

function get_default_branch_name(owner::AbstractString, repo::AbstractString)
    original_directory = pwd()
    dir = mktempdir(; cleanup = true)
    cd(dir)
    run(`git clone https://github.com/$(owner)/$(repo).git CLONE`)
    cd("CLONE")
    default_branch_name = chomp(read(`git rev-parse --abbrev-ref HEAD`, String))
    cd(original_directory)
    rm(dir; force = true, recursive = true)
    return default_branch_name
end

E.g.:

julia> default_branch_name = get_default_branch_name("JuliaRegistries", "RegistryCI.jl")
Cloning into 'CLONE'...
remote: Enumerating objects: 42, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 2070 (delta 17), reused 27 (delta 12), pack-reused 2028
Receiving objects: 100% (2070/2070), 877.82 KiB | 2.49 MiB/s, done.
Resolving deltas: 100% (1140/1140), done.
"master"

julia> @info "" default_branch_name
┌ Info:
└   default_branch_name = "master"

DilumAluthge avatar Dec 12 '20 05:12 DilumAluthge

It should be simpler, just doing a get_repo on the upstream ought to give us the default branch. I'll look into this tomorrow.

edit: s/tomorrow/EVENTUALLY/

christopher-dG avatar Dec 12 '20 06:12 christopher-dG