Improve support for web enqueue/dequeue
This change: * Returns the build/buildset oldrev through the REST API (this field was missing). * Updates the web UI so that when enqueuing or dequeueing a ref it will send exactly the oldrev/newrev values it received, including None/null. * No longer translate None to 40*'0' when creating internal management events. In concert, these changes allow a user to re-enqueue exactly as originally enqueued buildsets for branch tips (periodic pipeline) as well as ref updates (tag/post pipelines). Additionally, the re-enqueue method in the web UI is updated to support re-enqueing tag and branch heads (it only worked on change and ref-updates before). Finally, the buildset page is updated to show the old and new revs if they are non-null. Change-Id: I9886cd44f8b4bae6f4a5ce3644f0598a73ecfe0a
This commit is contained in:
parent
532c30469f
commit
6c1c91f8ba
|
@ -179,9 +179,8 @@ function Buildset({ buildset, timezone, tenant, user }) {
|
||||||
function enqueueConfirm() {
|
function enqueueConfirm() {
|
||||||
setShowEnqueueModal(false)
|
setShowEnqueueModal(false)
|
||||||
if (buildset.change === null) {
|
if (buildset.change === null) {
|
||||||
const oldrev = '0000000000000000000000000000000000000000'
|
enqueue_ref(tenant.apiPrefix, buildset.project, buildset.pipeline,
|
||||||
const newrev = buildset.newrev ? buildset.newrev : '0000000000000000000000000000000000000000'
|
buildset.ref, buildset.oldrev, buildset.newrev)
|
||||||
enqueue_ref(tenant.apiPrefix, buildset.project, buildset.pipeline, buildset.ref, oldrev, newrev)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(addNotification(
|
dispatch(addNotification(
|
||||||
{
|
{
|
||||||
|
@ -234,6 +233,32 @@ function Buildset({ buildset, timezone, tenant, user }) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderRefInfo(buildset) {
|
||||||
|
const refinfo = buildset.branch ? (
|
||||||
|
<>
|
||||||
|
<strong>Branch </strong> {buildset.branch}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<strong>Ref </strong> {buildset.ref}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
const oldrev = buildset.oldrev ? (
|
||||||
|
<><br/><strong>Old</strong> {buildset.oldrev}</>
|
||||||
|
) : ( <></> )
|
||||||
|
const newrev = buildset.newrev ? (
|
||||||
|
<><br/><strong>New</strong> {buildset.newrev}</>
|
||||||
|
) : ( <></> )
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{refinfo}
|
||||||
|
{oldrev}
|
||||||
|
{newrev}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Title headingLevel="h2">
|
<Title headingLevel="h2">
|
||||||
|
@ -275,18 +300,7 @@ function Buildset({ buildset, timezone, tenant, user }) {
|
||||||
<IconProperty
|
<IconProperty
|
||||||
WrapElement={ListItem}
|
WrapElement={ListItem}
|
||||||
icon={<CodeBranchIcon />}
|
icon={<CodeBranchIcon />}
|
||||||
value={
|
value={renderRefInfo(buildset)}/>
|
||||||
buildset.branch ? (
|
|
||||||
<>
|
|
||||||
<strong>Branch </strong> {buildset.branch}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<strong>Ref </strong> {buildset.ref}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<IconProperty
|
<IconProperty
|
||||||
WrapElement={ListItem}
|
WrapElement={ListItem}
|
||||||
icon={<StreamIcon />}
|
icon={<StreamIcon />}
|
||||||
|
|
|
@ -64,16 +64,7 @@ class Change extends React.Component {
|
||||||
let changeRef = change.ref
|
let changeRef = change.ref
|
||||||
this.setState(() => ({ showDequeueModal: false }))
|
this.setState(() => ({ showDequeueModal: false }))
|
||||||
// post-merge
|
// post-merge
|
||||||
if (/^[0-9a-f]{40}$/.test(changeId)) {
|
if (changeId !== 'N/A') {
|
||||||
dequeue_ref(tenant.apiPrefix, projectName, pipeline.name, changeRef)
|
|
||||||
.then(() => {
|
|
||||||
this.props.dispatch(fetchStatusIfNeeded(tenant))
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.props.dispatch(addDequeueError(error))
|
|
||||||
})
|
|
||||||
// pre-merge, ie we have a change id
|
|
||||||
} else if (changeId !== 'N/A') {
|
|
||||||
dequeue(tenant.apiPrefix, projectName, pipeline.name, changeId)
|
dequeue(tenant.apiPrefix, projectName, pipeline.name, changeId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.props.dispatch(fetchStatusIfNeeded(tenant))
|
this.props.dispatch(fetchStatusIfNeeded(tenant))
|
||||||
|
@ -82,12 +73,13 @@ class Change extends React.Component {
|
||||||
this.props.dispatch(addDequeueError(error))
|
this.props.dispatch(addDequeueError(error))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.props.dispatch(addNotification({
|
dequeue_ref(tenant.apiPrefix, projectName, pipeline.name, changeRef)
|
||||||
url: null,
|
.then(() => {
|
||||||
status: 'Invalid change ' + changeRef + ' on project ' + projectName,
|
this.props.dispatch(fetchStatusIfNeeded(tenant))
|
||||||
text: '',
|
})
|
||||||
type: 'error',
|
.catch(error => {
|
||||||
}))
|
this.props.dispatch(addDequeueError(error))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6450,8 +6450,8 @@ class ChangeManagementEvent(ManagementEvent):
|
||||||
else:
|
else:
|
||||||
self.change_number, self.patch_number = (None, None)
|
self.change_number, self.patch_number = (None, None)
|
||||||
self.ref = ref
|
self.ref = ref
|
||||||
self.oldrev = oldrev or '0000000000000000000000000000000000000000'
|
self.oldrev = oldrev
|
||||||
self.newrev = newrev or '0000000000000000000000000000000000000000'
|
self.newrev = newrev
|
||||||
self.timestamp = time.time()
|
self.timestamp = time.time()
|
||||||
span = trace.get_current_span()
|
span = trace.get_current_span()
|
||||||
self.span_context = tracing.getSpanContext(span)
|
self.span_context = tracing.getSpanContext(span)
|
||||||
|
|
|
@ -1391,6 +1391,7 @@ class ZuulWebAPI(object):
|
||||||
'change': buildset.change,
|
'change': buildset.change,
|
||||||
'patchset': buildset.patchset,
|
'patchset': buildset.patchset,
|
||||||
'ref': buildset.ref,
|
'ref': buildset.ref,
|
||||||
|
'oldrev': buildset.oldrev,
|
||||||
'newrev': buildset.newrev,
|
'newrev': buildset.newrev,
|
||||||
'ref_url': buildset.ref_url,
|
'ref_url': buildset.ref_url,
|
||||||
'event_id': buildset.event_id,
|
'event_id': buildset.event_id,
|
||||||
|
@ -1487,6 +1488,7 @@ class ZuulWebAPI(object):
|
||||||
'change': buildset.change,
|
'change': buildset.change,
|
||||||
'patchset': buildset.patchset,
|
'patchset': buildset.patchset,
|
||||||
'ref': buildset.ref,
|
'ref': buildset.ref,
|
||||||
|
'oldrev': buildset.oldrev,
|
||||||
'newrev': buildset.newrev,
|
'newrev': buildset.newrev,
|
||||||
'ref_url': buildset.ref_url,
|
'ref_url': buildset.ref_url,
|
||||||
'event_id': buildset.event_id,
|
'event_id': buildset.event_id,
|
||||||
|
|
Loading…
Reference in New Issue