search_versions: Search a Set of Version Numbers

Description Usage Arguments Value Examples

View source: R/search_versions.R

Description

This function makes it easy to find a version number in an existing set by indexing from another version number. This is particularly useful when you want to know, e.g. what the last development version was before a certain patch version, or what the last minor version was before a certain major version.

Usage

1
2
3
4
5
6
search_versions(
  data,
  reference,
  which = length(reference[[1]]),
  increment = -1
)

Arguments

data

Existing version numbers to search

reference

The version number to index from - can be given as a character for convenience.

which

The version number part to be cycled through - can either be supplied as a number or one of the part-names as set in getOption("versionr.parts"). By default this will be the same as the last version number part of reference, giving a more convenient interface. See examples for details.

increment

The number iterations to look forwards/backwards - in most cases this will be -1 to look for the previous version.

Value

A version number

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
data <- version_number("1.0.0", "1.2.0", "1.2.0.1", "2.0.0")

# Find the previous dev version
search_versions(data, "2.0.0", "dev")

# Find the previous patch version
search_versions(data, "2.0.0", "patch")

# In some cases these will be the same:
search_versions(data, "1.2.0", "dev")
search_versions(data, "1.2.0", "patch")

# If not supplied, the part that gets incremented will be chosen based on
# the specificity of the reference number:
search_versions(data, "2.0.0.0")
search_versions(data, "2.0.0")

# You can use different increments, but usually this isn't needed
search_versions(data, "2.0.0.0", increment = -2)
search_versions(data, "1.0.0", increment = 1)

wurli/versionr documentation built on Dec. 23, 2021, 6:13 p.m.