determine_ref: Determine the branch/tag to install based on feature (staging...

View source: R/ref_strategy.R

determine_refR Documentation

Determine the branch/tag to install based on feature (staging rules)

Description

Return the git ref (tag or branch) of the repo to install given the available branches and tags.

Usage

determine_ref(ref, available_refs, fallback_branch = "main", branch_sep = "@")

Arguments

ref

ref we want to build

available_refs

data.frame with columns ref the names of the available refs and type (branch or tag)

fallback_branch

the default branch to try to use if no other matches found

branch_sep

separator between branches in feature, / does not work well with git because it clashes with the filesystem paths

Details

A ref is either a tag or branches separated by slashes of the form name1@name2@...@nameN. Where separator is specified by branch_sep argument

This function checks for an exact match for the tag if this is not found then among the available branches, it searches in the order name1@name2@...@nameN, name2@name3@...@nameN, name3@name4@...@nameN, ..., nameN

Value

branch/tag to choose to match feature, error if no suitable branch was provided with the type attribute "tag" or "branch"

Examples

determine_ref(
  "feature1",
  data.frame(ref = c("main", "feature1"), type = "branch")
) == structure("feature1", type = "branch")

determine_ref(
  "feature1@devel",
  data.frame(ref = c("main", "devel", "feature1"), type = "branch")
) == structure("devel", type = "branch")

determine_ref(
  ref = "fix1@feature1@devel",
  available_refs = data.frame(
    ref = c(
      "main", "devel", "feature1", "feature1@devel",
      "fix1@feature1@devel", "fix1"
    ),
    type = "branch"
  )
) == structure("fix1@feature1@devel", type = "branch")

determine_ref(
  "fix1@feature1@devel",
  data.frame(
    ref = c("main", "devel", "feature1", "feature1@devel", "fix1"),
    type = "branch"
  )
) == structure("feature1@devel", type = "branch")

determine_ref(
  "fix1@feature1@devel",
  data.frame(ref = c("main", "devel", "feature1", "fix1"), type = "branch")
) == structure("devel", type = "branch")

determine_ref("feature1@release", data.frame(ref = c("main", "devel"), type = "branch"))

# error because neither `feature1@release` nor `release` branch exists
# determine_ref("feature1@release", data.frame(ref = c("master", "devel"), type = "branch"))

# tag examples
determine_ref(
  "v0.1",
  data.frame(ref = c("main", "devel", "feature1", "v0.1"), type = c(rep("branch", 3), "tag"))
) == structure("v0.1", type = "tag")

determine_ref(
  "v0.2",
  data.frame(ref = c("main", "devel", "feature1", "v0.1"), type = c(rep("branch", 3), "tag"))
) == structure("main", type = "branch")


openpharma/staged.dependencies documentation built on Aug. 27, 2023, 10:17 a.m.