diff --git a/endpoints/trigger.py b/endpoints/trigger.py index 053d47d57..61c5e7ef8 100644 --- a/endpoints/trigger.py +++ b/endpoints/trigger.py @@ -231,15 +231,16 @@ class GithubBuildTrigger(BuildTrigger): return repos_by_org - def matches_branch(self, branch_name, regex): + def matches_ref(self, ref, regex): + match_string = ref.split('/', 1)[1] if not regex: return False - m = regex.match(branch_name) + m = regex.match(match_string) if not m: return False - return len(m.group(0)) == len(branch_name) + return len(m.group(0)) == len(match_string) def list_build_subdirs(self, auth_token, config): gh_client = self._get_client(auth_token) @@ -250,11 +251,11 @@ class GithubBuildTrigger(BuildTrigger): # Find the first matching branch. branches = None - if 'branch_regex' in config: + if 'branchtag_regex' in config: try: - regex = re.compile(config['branch_regex']) + regex = re.compile(config['branchtag_regex']) branches = [branch.name for branch in repo.get_branches() - if self.matches_branch(branch.name, regex)] + if self.matches_ref('refs/heads/' + branch.name, regex)] except: pass @@ -370,14 +371,13 @@ class GithubBuildTrigger(BuildTrigger): commit_sha = payload['head_commit']['id'] commit_message = payload['head_commit'].get('message', '') - if 'branch_regex' in config: + if 'branchtag_regex' in config: try: - regex = re.compile(config['branch_regex']) + regex = re.compile(config['branchtag_regex']) except: regex = re.compile('.*') - branch = ref.split('/')[-1] - if not self.matches_branch(branch, regex): + if not self.matches_ref(ref, regex): raise SkipRequestException() if should_skip_commit(commit_message): @@ -414,6 +414,19 @@ class GithubBuildTrigger(BuildTrigger): def list_field_values(self, auth_token, config, field_name): + if field_name == 'refs': + branches = self.list_field_values(auth_token, config, 'branch_name') + tags = self.list_field_values(auth_token, config, 'tag_name') + + return ([{'kind': 'branch', 'name': b} for b in branches] + + [{'kind': 'tag', 'name': tag} for tag in tags]) + + if field_name == 'tag_name': + gh_client = self._get_client(auth_token) + source = config['build_source'] + repo = gh_client.get_repo(source) + return [tag.name for tag in repo.get_tags()] + if field_name == 'branch_name': gh_client = self._get_client(auth_token) source = config['build_source'] diff --git a/static/css/quay.css b/static/css/quay.css index 58e53af60..f0bf4883d 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -19,6 +19,18 @@ } } +.dropdown.input-group-addon { + padding: 0px; + border: 0px; + background-color: transparent; + text-align: left; +} + +.dropdown.input-group-addon .dropdown-toggle { + border-left: 0px; + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} #quay-logo { width: 100px; @@ -4109,20 +4121,37 @@ pre.command:before { border-bottom-left-radius: 0px; } -.trigger-setup-github-element .branch-reference.not-match { - color: #ccc !important; +.trigger-setup-github-element .ref-reference { + color: #ccc; } -.trigger-setup-github-element .branch-reference.not-match a { - color: #ccc !important; +.trigger-setup-github-element .ref-reference span { + cursor: pointer; text-decoration: line-through; } -.trigger-setup-github-element .branch-filter { +.trigger-setup-github-element .ref-reference:hover { + color: #3276b1; +} + +.trigger-setup-github-element .ref-reference:hover span { + text-decoration: none; +} + +.trigger-setup-github-element .ref-reference.match { + color: black; +} + +.trigger-setup-github-element .ref-reference.match span { + text-decoration: none; + cursor: default; +} + +.trigger-setup-github-element .ref-filter { white-space: nowrap; } -.trigger-setup-github-element .branch-filter span { +.trigger-setup-github-element .ref-filter span { display: inline-block; } @@ -4145,19 +4174,37 @@ pre.command:before { padding-left: 6px; } -.trigger-setup-github-element .matching-branches { +.trigger-setup-github-element .matching-refs { margin: 0px; padding: 0px; margin-left: 10px; display: inline-block; } -.trigger-setup-github-element .matching-branches li:before { +.trigger-setup-github-element .ref-matches { + padding-left: 70px; + position: relative; + margin-bottom: 10px; +} + +.trigger-setup-github-element .ref-matches .kind { + font-weight: bold; + position: absolute; + top: 0px; + left: 0px; +} + +.trigger-setup-github-element .matching-refs.tags li:before { + content: "\f02b"; + font-family: FontAwesome; +} + +.trigger-setup-github-element .matching-refs.branches li:before { content: "\f126"; font-family: FontAwesome; } -.trigger-setup-github-element .matching-branches li { +.trigger-setup-github-element .matching-refs li { list-style: none; display: inline-block; margin-left: 10px; @@ -4333,11 +4380,14 @@ pre.command:before { } .trigger-pull-credentials { - margin-top: 4px; padding-left: 26px; font-size: 12px; } +.trigger-pull-credentials .entity-reference { + margin-left: 10px; +} + .trigger-pull-credentials .context-tooltip { color: gray; margin-right: 4px; @@ -4345,7 +4395,8 @@ pre.command:before { .trigger-description .trigger-description-subtitle { display: inline-block; - margin-right: 34px; + width: 100px; + margin-bottom: 4px; } .trigger-option-section:not(:first-child) { diff --git a/static/directives/trigger-description.html b/static/directives/trigger-description.html index 4d9eb0930..91000dd1e 100644 --- a/static/directives/trigger-description.html +++ b/static/directives/trigger-description.html @@ -4,9 +4,9 @@ Push to GitHub repository {{ trigger.config.build_source }}
{{ state.branchFilter }}
+ {{ state.branchTagFilter }}