11import * as vscode from "vscode" ;
2+ import { WorkflowJob , WorkflowRun } from "../model" ;
23import { GitHubRepoContext } from "../git/repository" ;
3- import { updateDecorations } from "../logs/formatProvider" ;
4- import { getLogInfo } from "../logs/logInfo" ;
5- import { buildLogURI } from "../logs/scheme" ;
6- import { WorkflowJob } from "../store/WorkflowJob" ;
7- import { WorkflowStep } from "../model" ;
4+ import { integer } from "vscode-languageclient" ;
5+ import { WorkflowRunCommandArgs , WorkflowRunNode } from "../treeViews/shared/workflowRunNode" ;
6+ import { WorkflowJobNode } from "../treeViews/shared/workflowJobNode" ;
87
9- export interface OpenWorkflowStepLogsCommandArgs {
10- gitHubRepoContext : GitHubRepoContext ;
11- job : WorkflowJob ;
12- step : WorkflowStep ;
13- }
8+ // export interface OpenWorkflowStepLogsCommandArgs {
9+ // gitHubRepoContext: GitHubRepoContext;
10+ // job: WorkflowJob;
11+ // run: WorkflowRun;
12+ // }
13+
14+ export type WorkflowStepCommandArgs = Pick < WorkflowJobNode , "job" > ;
1415
1516export function registerOpenWorkflowStepLogs ( context : vscode . ExtensionContext ) {
1617 context . subscriptions . push (
17- vscode . commands . registerCommand ( "github-actions.step.logs" , async ( args : OpenWorkflowStepLogsCommandArgs ) => {
18- const gitHubRepoContext = args . gitHubRepoContext ;
19- const job = args . job ;
20- const step = args . step ;
18+ vscode . commands . registerCommand ( "github-actions.step.logs" , async ( args : WorkflowStepCommandArgs ) => {
19+ const job = args . job . job ;
20+ let url = job . html_url ?? "" ;
21+ const stepName = args . step . name ;
2122
22- const uri = buildLogURI (
23- `%23${ job . job . run_id } - ${ job . job . name } ` ,
24- gitHubRepoContext . owner ,
25- gitHubRepoContext . name ,
26- job . job . id
27- ) ;
23+ const index = job . steps && job . steps . findIndex ( step => step . name === stepName ) + 1 ;
2824
29- const doc = await vscode . workspace . openTextDocument ( uri ) ;
30- const editor = await vscode . window . showTextDocument ( doc , {
31- preview : false
32- } ) ;
33-
34- const logInfo = getLogInfo ( uri ) ;
35- if ( ! logInfo ) {
36- throw new Error ( "Could not get log info" ) ;
25+ if ( url && index ) {
26+ url = url + "#step:" + index . toString ( ) + ":1" ;
3727 }
3828
39- const section = logInfo . sections . find ( s => s . name === step . name ) ;
40- const startLine = section ? section . start : 0 ;
41- const endLine = section ? section . end : 0 ;
42-
43-
44- const stepInfo = {
45- updatedLogLines : logInfo [ "updatedLogLines" ] . slice ( startLine , endLine ) ,
46- sections : logInfo [ "sections" ] . filter ( s => s . name === step . name ) ,
47- styleFormats : logInfo [ "styleFormats" ] . filter ( s => s . line >= startLine && s . line <= endLine )
48- } ;
49-
50-
51- // Custom formatting after the editor has been opened
52- updateDecorations ( editor , stepInfo ) ;
29+ await vscode . env . openExternal ( vscode . Uri . parse ( url ) ) ;
5330 } )
5431 ) ;
55- }
32+ }
0 commit comments