Add support for tags.

This commit is contained in:
Tom Alexander
2024-09-29 00:06:46 -04:00
parent 1efd7b1d73
commit a2aca6d2f1
6 changed files with 205 additions and 42 deletions

View File

@@ -34,7 +34,7 @@ pub(crate) async fn discover_matching_push_triggers<RE: AsRef<str>>(
remote_config: &RemoteConfig,
) -> Result<Vec<PipelineTemplate>, Box<dyn std::error::Error>> {
let mut ret = Vec::new();
let ref_to_branch_regex = Regex::new(r"refs/heads/(?P<branch>.+)")?;
let ref_to_branch_regex = Regex::new(r"refs/(heads|tags)/(?P<branch>.+)")?;
let captures = ref_to_branch_regex
.captures(git_ref.as_ref())
.ok_or("Could not find branch name.")?;

View File

@@ -166,7 +166,7 @@ pub(crate) trait PipelineParamters {
impl PipelineParamters for HookPush {
fn get_pull_base_ref(&self) -> Result<Cow<str>, Box<dyn std::error::Error>> {
let ref_to_branch_regex = Regex::new(r"refs/heads/(?P<branch>.+)")?;
let ref_to_branch_regex = Regex::new(r"refs/(heads|tags)/(?P<branch>.+)")?;
let captures = ref_to_branch_regex
.captures(self.ref_field.as_str())
.ok_or("Could not find branch name.")?;

View File

@@ -62,7 +62,7 @@ impl RemoteConfig {
.iter()
.map(|s| Regex::new(s.as_str()))
.collect::<Result<_, _>>()?;
if !push.branches.is_empty() && !match_regex.iter().any(|r| r.is_match(branch)) {
if !push.branches.is_empty() && match_regex.iter().any(|r| r.is_match(branch)) {
continue;
}