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() {
|
||||
setShowEnqueueModal(false)
|
||||
if (buildset.change === null) {
|
||||
const oldrev = '0000000000000000000000000000000000000000'
|
||||
const newrev = buildset.newrev ? buildset.newrev : '0000000000000000000000000000000000000000'
|
||||
enqueue_ref(tenant.apiPrefix, buildset.project, buildset.pipeline, buildset.ref, oldrev, newrev)
|
||||
enqueue_ref(tenant.apiPrefix, buildset.project, buildset.pipeline,
|
||||
buildset.ref, buildset.oldrev, buildset.newrev)
|
||||
.then(() => {
|
||||
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 (
|
||||
<>
|
||||
<Title headingLevel="h2">
|
||||
|
@ -275,18 +300,7 @@ function Buildset({ buildset, timezone, tenant, user }) {
|
|||
<IconProperty
|
||||
WrapElement={ListItem}
|
||||
icon={<CodeBranchIcon />}
|
||||
value={
|
||||
buildset.branch ? (
|
||||
<>
|
||||
<strong>Branch </strong> {buildset.branch}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<strong>Ref </strong> {buildset.ref}
|
||||
</>
|
||||
)
|
||||
}
|
||||
/>
|
||||
value={renderRefInfo(buildset)}/>
|
||||
<IconProperty
|
||||
WrapElement={ListItem}
|
||||
icon={<StreamIcon />}
|
||||
|
|
|
@ -64,16 +64,7 @@ class Change extends React.Component {
|
|||
let changeRef = change.ref
|
||||
this.setState(() => ({ showDequeueModal: false }))
|
||||
// post-merge
|
||||
if (/^[0-9a-f]{40}$/.test(changeId)) {
|
||||
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') {
|
||||
if (changeId !== 'N/A') {
|
||||
dequeue(tenant.apiPrefix, projectName, pipeline.name, changeId)
|
||||
.then(() => {
|
||||
this.props.dispatch(fetchStatusIfNeeded(tenant))
|
||||
|
@ -82,12 +73,13 @@ class Change extends React.Component {
|
|||
this.props.dispatch(addDequeueError(error))
|
||||
})
|
||||
} else {
|
||||
this.props.dispatch(addNotification({
|
||||
url: null,
|
||||
status: 'Invalid change ' + changeRef + ' on project ' + projectName,
|
||||
text: '',
|
||||
type: 'error',
|
||||
}))
|
||||
dequeue_ref(tenant.apiPrefix, projectName, pipeline.name, changeRef)
|
||||
.then(() => {
|
||||
this.props.dispatch(fetchStatusIfNeeded(tenant))
|
||||
})
|
||||
.catch(error => {
|
||||
this.props.dispatch(addDequeueError(error))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6450,8 +6450,8 @@ class ChangeManagementEvent(ManagementEvent):
|
|||
else:
|
||||
self.change_number, self.patch_number = (None, None)
|
||||
self.ref = ref
|
||||
self.oldrev = oldrev or '0000000000000000000000000000000000000000'
|
||||
self.newrev = newrev or '0000000000000000000000000000000000000000'
|
||||
self.oldrev = oldrev
|
||||
self.newrev = newrev
|
||||
self.timestamp = time.time()
|
||||
span = trace.get_current_span()
|
||||
self.span_context = tracing.getSpanContext(span)
|
||||
|
|
|
@ -1391,6 +1391,7 @@ class ZuulWebAPI(object):
|
|||
'change': buildset.change,
|
||||
'patchset': buildset.patchset,
|
||||
'ref': buildset.ref,
|
||||
'oldrev': buildset.oldrev,
|
||||
'newrev': buildset.newrev,
|
||||
'ref_url': buildset.ref_url,
|
||||
'event_id': buildset.event_id,
|
||||
|
@ -1487,6 +1488,7 @@ class ZuulWebAPI(object):
|
|||
'change': buildset.change,
|
||||
'patchset': buildset.patchset,
|
||||
'ref': buildset.ref,
|
||||
'oldrev': buildset.oldrev,
|
||||
'newrev': buildset.newrev,
|
||||
'ref_url': buildset.ref_url,
|
||||
'event_id': buildset.event_id,
|
||||
|
|
Loading…
Reference in New Issue