Skip to content

Commit

Permalink
added allow_regex to help with issue MarkEdmondson1234#172
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Aug 4, 2022
1 parent b124b97 commit 3f671e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions R/buildtrigger_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,19 @@ is.gar_webhookConfig <- function(x) {
#' @noRd
GitRepoSource <- function(uri,
ref,
repoType = c("GITHUB","CLOUD_SOURCE_REPOSITORIES")){
repoType = c("GITHUB","CLOUD_SOURCE_REPOSITORIES"),
allow_regex = FALSE){

assert_that(
is.string(uri),
is.string(ref),
isTRUE(grepl("^refs/", ref)),
!grepl("[^A-Za-z0-9/.]", ref) # regex not allowed
is.string(ref)
)
if (!allow_regex) {
assert_that(
isTRUE(grepl("^refs/", ref)),
!grepl("[^A-Za-z0-9/.]", ref) # regex not allowed
)
}

repoType <- match.arg(repoType)

Expand All @@ -202,7 +207,7 @@ is.gitRepoSource <- function(x){
inherits(x, "gar_gitRepoSource")
}

as.gitRepoSource <- function(x){
as.gitRepoSource <- function(x, allow_regex = FALSE){
if(!is.buildtrigger_repo(x)){
stop("is not buildtrigger_repo")
}
Expand All @@ -222,7 +227,8 @@ as.gitRepoSource <- function(x){
uri = sprintf("https://github.com/%s/%s",
x$repo$owner, x$repo$name),
ref = ref,
repoType = "GITHUB"
repoType = "GITHUB",
allow_regex = allow_regex
)
)
}
Expand All @@ -242,7 +248,8 @@ as.gitRepoSource <- function(x){
uri = sprintf("https://source.developers.google.com/p/%s/r/%s",
x$repo$projectId, x$repo$repoName),
ref = ref,
repoType = "CLOUD_SOURCE_REPOSITORIES"
repoType = "CLOUD_SOURCE_REPOSITORIES",
allow_regex = allow_regex
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/buildtriggers.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ cr_buildtrigger <- function(build,

if (!is.null(sourceToBuild)) {
assert_that(is.buildtrigger_repo(sourceToBuild))
sourceToBuild <- as.gitRepoSource(sourceToBuild)
sourceToBuild <- as.gitRepoSource(sourceToBuild, allow_regex = TRUE)
}

trigger_cloudsource <- NULL
Expand Down

0 comments on commit 3f671e4

Please sign in to comment.