openpharma / staged.dependencies

R package to implement development stages for package development
https://openpharma.github.io/staged.dependencies/
MIT License
12 stars 3 forks source link

Programmatically get default branch name #106

Closed nikolas-burkoff closed 2 years ago

nikolas-burkoff commented 3 years ago

At the moment this is hard-coded as "main" but I think we can get the default branch out and pass that as fallback argument to determine_ref

image

nikolas-burkoff commented 2 years ago

Does this work with graphQL - if so do this

nikolas-burkoff commented 2 years ago

This can be done in github:

repository(owner: "openpharma", name: "stageddeps.garden") {
  defaultBranchRef {
    name
  }
} 

and gitlab:

{
  project(fullPath: "path/to/repo") {
    repository {
      rootRef
    }
  }
}
nikolas-burkoff commented 2 years ago

I can't find a way of doing this with git2r - I think this works:

image

It adds gert as an imports (but that is already required as we import devtools which depends on usethis which imports gert) - also I think we should move to using gert anyway

(Note usethis has a function git_branch_default which may be helpful)

nikolas-burkoff commented 2 years ago

Closing in favour of https://github.com/openpharma/staged.dependencies/issues/134