triggers: metadata.commit_sha -> metadata.commit

This resolves an issue where the custom-git trigger's public facing
schema was not the same as the internal metadata schema. Instead of
breaking users, we rework the internal metadata schema to be the same as
the custom-git JSON schema. This commit also updates everything that
used `metadata.commit_sha` including the test database.
This commit is contained in:
Jimmy Zelinskie 2015-06-02 15:32:28 -04:00
parent b7adacb36b
commit e01bdd4ab0
7 changed files with 13 additions and 13 deletions

View file

@ -139,7 +139,7 @@ class BuildComponent(BaseComponent):
if build_job.repo_build.trigger.private_key is not None:
build_arguments['git'] = {
'url': build_config['trigger_metadata'].get('git_url', ''),
'sha': build_config['trigger_metadata'].get('commit_sha', ''),
'sha': build_config['trigger_metadata'].get('commit', ''),
'private_key': build_job.repo_build.trigger.private_key,
}

View file

@ -478,7 +478,7 @@ class BitbucketBuildTrigger(BuildTriggerHandler):
}
metadata = {
'commit_sha': commit_sha,
'commit': commit_sha,
'ref': ref,
'default_branch': default_branch,
'git_url': 'git@bitbucket.org:%s/%s.git' % (namespace, name),
@ -822,7 +822,7 @@ class GithubBuildTrigger(BuildTriggerHandler):
# Build and set the metadata.
metadata = {
'commit_sha': commit_sha,
'commit': commit_sha,
'ref': ref,
'default_branch': repo.default_branch,
'git_url': repo.ssh_url,
@ -936,7 +936,7 @@ class CustomBuildTrigger(BuildTriggerHandler):
'commit': {
'type': 'string',
'description': 'first 7 characters of the SHA-1 identifier for a git commit',
'pattern': '^([A-Fa-f0-9]{7})$',
'pattern': '^([A-Fa-f0-9]{7,})$',
},
'ref': {
'type': 'string',
@ -1057,7 +1057,7 @@ class CustomBuildTrigger(BuildTriggerHandler):
config = self.config
metadata = {
'commit_sha': commit_sha,
'commit': commit_sha,
'git_url': config['build_source'],
}
@ -1307,7 +1307,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
author = None
metadata = {
'commit_sha': commit['id'],
'commit': commit['id'],
'ref': ref,
'default_branch': repo['default_branch'],
'git_url': repo['ssh_url_to_repo'],

View file

@ -439,7 +439,7 @@ def populate_database():
'docker_tags': ['latest'],
'build_subdir': '',
'trigger_metadata': {
'commit_sha': '3482adc5822c498e8f7db2e361e8d57b3d77ddd9',
'commit': '3482adc5822c498e8f7db2e361e8d57b3d77ddd9',
'ref': 'refs/heads/master',
'default_branch': 'master'
}

View file

@ -21,14 +21,14 @@
<div class="tbd-content" ng-switch-when="commitsha">
Triggered by commit
<span class="source-commit-link"
commit-sha="build.trigger_metadata.commit_sha"></span>
commit-sha="build.trigger_metadata.commit"></span>
</div>
<!-- Full Commit Information -->
<div class="tbd-content" ng-switch-when="fullcommit">
<div class="commit-message">
<span class="anchor" is-only-text="!TriggerService.getFullLinkTemplate(build, 'commit')"
target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', build.trigger_metadata.commit_sha) }}">
target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', build.trigger_metadata.commit) }}">
{{ build.trigger_metadata.commit_info.message }}
</span>
</div>
@ -46,7 +46,7 @@
</span>
</span>
<span class="source-commit-link"
commit-sha="build.trigger_metadata.commit_sha"
commit-sha="build.trigger_metadata.commit"
url-template="TriggerService.getFullLinkTemplate(build, 'commit')"></span>
<span class="source-ref-link"
ref="build.trigger_metadata.ref"

View file

@ -45,7 +45,7 @@ angular.module('quay').directive('repoPanelBuilds', function () {
var commit_sha = null;
if (build_info.trigger_metadata) {
commit_sha = build_info.trigger_metadata.commit_sha;
commit_sha = build_info.trigger_metadata.commit;
}
return $.extend(build_info, {

View file

@ -33,7 +33,7 @@ angular.module('quay').directive('triggeredBuildDescription', function () {
return;
}
if (build.trigger && build.trigger.build_source && triggerMetadata.commit_sha) {
if (build.trigger && build.trigger.build_source && triggerMetadata.commit) {
$scope.infoDisplay = 'commitsha';
return;
}
@ -43,4 +43,4 @@ angular.module('quay').directive('triggeredBuildDescription', function () {
}
};
return directiveDefinitionObject;
});
});

Binary file not shown.