-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format precondition error in commit as in merge (#1548)
- Loading branch information
Showing
3 changed files
with
48 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {Alert} from "react-bootstrap"; | ||
import {API_ENDPOINT} from "../actions/api"; | ||
import ClipboardButton from "./ClipboardButton"; | ||
import React from "react"; | ||
|
||
|
||
function extractActionRunID(err) { | ||
const m = /^Error: (\S+) hook aborted, run id '([^']+)'/.exec(err); | ||
return m ? m[2] : ''; | ||
} | ||
|
||
function extractActionHookRunID(err) { | ||
const m = /^\t\* hook run id '([^']+)' failed/.exec(err); | ||
return m ? m[1] : ''; | ||
} | ||
|
||
export function formatAlertText(repositoryId, err) { | ||
if (!err) { | ||
return ''; | ||
} | ||
const lines = err.split('\n'); | ||
if (lines.length === 1) { | ||
return <Alert.Heading>{err}</Alert.Heading>; | ||
} | ||
const runID = extractActionRunID(err); | ||
let result = lines.map((line, i) => { | ||
if (runID) { | ||
const hookRunID = extractActionHookRunID(line); | ||
if (hookRunID) { | ||
const link = `${API_ENDPOINT}/repositories/${repositoryId}/actions/runs/${runID}/hooks/${hookRunID}/output`; | ||
return <p key={i}><Alert.Link target="_blank" download={runID+'-'+hookRunID+'.log'} href={link}>{line}</Alert.Link></p>; | ||
} | ||
} | ||
return <p key={i}>{line}</p>; | ||
}); | ||
if (runID) { | ||
const cmd = `lakectl actions runs describe lakefs://${repositoryId} ${runID}`; | ||
result = <>{result}<hr/>For detailed information run:<br/>{cmd}<ClipboardButton variant="link" text={cmd} tooltip="Copy"/></>; | ||
} | ||
return result; | ||
} |