diff --git a/package.json b/package.json index d41043f..79c1188 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "aramoks-clearcase", "displayName": "Aramok's Clearcase", "description": "IBM Rational Clearcase integration with Visual Studio Code", - "version": "1.0.13", + "version": "1.0.16", "author": { "name": "Sencer Aramok", "email": "mohorame@gmail.com" diff --git a/src/extension.ts b/src/extension.ts index 92db45f..d800334 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -23,11 +23,11 @@ export interface HistoryData { data: HistoryData[]; version: string; username: string; - operation:string; - type:string; - time:string; - icon:string; - comment?:string; + operation: string; + type: string; + time: string; + icon: string; + comment?: string; } let cleartool = new ClearTool(); @@ -144,21 +144,22 @@ function cleartoolDescribeRealFile(realFilePath: String) { fileStatus.hide(); viewStatus.text = `$(git-branch) No Version`; }, (stdout) => { - if ((matches = stdout.match(/(?<=version:\s\\main\\).*/)) !== null) { + if ((matches = stdout.match(/(?<=@@\\main\\).*(?=")/)) !== null) { viewStatus.text = `$(git-branch) ${matches.toString()}`; if (stdout.indexOf("CHECKEDOUT") !== -1) { setContextCriteria(FileState.CheckedOut); - fileStatus.text = `$(git-branch) ` + datePriorToNowRexExp(stdout.match(/(?<=checked out\s)(\S)*/)); + + fileStatus.text = `$(git-branch) ` + stdout.match(/(?<=by\s).*(?=\s)/) + datePriorToNowRexExp(stdout.match(/(?<=checked out\s)(\S)*/)); fileState.text = `$(verified) Checked Out`; } else { setContextCriteria(FileState.Locked); - fileStatus.text = `$(git-branch) ` + datePriorToNowRexExp(stdout.match(/(?<=created\s)(\S)*(?=,|\+)/)); + fileStatus.text = `$(git-branch) ` + stdout.match(/(?<=by\s).*(?=\s)/) + datePriorToNowRexExp(stdout.match(/(?<=created\s)(\S)*(?=,|\+)/)); fileState.text = `$(lock) Locked`; } } else { setContextCriteria(FileState.Private); viewStatus.text = `$(git-branch) No Version`; - fileStatus.text = `$(git-branch) ` + datePriorToNowRexExp(stdout.match(/(?<=Modified:\s).*/)); + fileStatus.text = `$(git-branch) ` + stdout.match(/(?<=by\s).*(?=\s)/) + datePriorToNowRexExp(stdout.match(/(?<=Modified:\s).*/)); fileState.text = `$(file-code) Private File`; } }); @@ -276,89 +277,85 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor((textEditor: vscode.TextEditor | undefined): void => { - cleartoolDescribeFile(textEditor); - let datas: HistoryData[] = []; - cleartool.run_command("lshistory ", "asd", (exception, stderr) => { - showMessage(stderr, NotificationType.Error); - }, (stderr) => { - showMessage(stderr, NotificationType.Error); - }, (stdout) => { - var lines = stdout.split('\n'); - let lastData: HistoryData; - lines.forEach(line => { - if (!line.startsWith(' ')) { - //(?<=@@\\|from\s)\S*(?="|\s) // match /main/ - //(?<=@@\\)\S*(?=") - //(?<=@@\\|from\s\\)\S*(?=\s|") - let root :RegExpMatchArray | null = line.match(/(?<=@@\\|from\s\\)[\w|\\]*/); - if (root) { - let matches: RegExpMatchArray | null = line.split(/\s+/); - if(matches){ - let time: string = matches[0].toString(); - let username: string = matches[1].toString(); - let operation: string = matches[2].toString(); - let type: string = matches[3].toString(); - let delimiter: string[] = root.toString().split("\\"); - let seeker: HistoryData[] = datas; - delimiter.forEach((version, index) => { - let dataFound: HistoryData | undefined; - dataFound = seeker.find(data => data.version === version ); - if (dataFound === undefined) { - - if(operation ==='checkout'){ - seeker.push(lastData = { version: version , icon:'\u2713' , username:username, operation:operation, type:type , time:time, data: [] }); - seeker = lastData.data; - }else{ - seeker.push(lastData = { version: version , icon:'\u2937' , username:username , operation:operation, type:type , time:time, data: [] }); - seeker = lastData.data; - } - } else { - if (index === delimiter.length - 1) { - switch(type){ - case 'version': - if(dataFound.operation === 'checkout'){ - seeker.push(lastData = { version: version , icon:'\u2937' , username:username , operation:operation, type:type , time:time, data: [] }); + //cleartoolDescribeFile(textEditor); + if (textEditor && textEditor.document.uri.toString().startsWith("file:")) { + fileState.text = `$(repo-sync~spin) Describe...`; + realLocation(textEditor.document.fileName, (realFilePath: String) => { + cleartoolDescribeRealFile(realFilePath); + + let datas: HistoryData[] = []; + cleartool.run_command("lshistory ", realFilePath, (exception, stderr) => { + showMessage(stderr, NotificationType.Error); + }, (stderr) => { + showMessage(stderr, NotificationType.Error); + }, (stdout) => { + var lines = stdout.split('\n'); + let lastData: HistoryData; + lines.forEach(line => { + if (!line.startsWith(' ')) { + //(?<=@@\\|from\s)\S*(?="|\s) // match /main/ + //(?<=@@\\)\S*(?=") + //(?<=@@\\|from\s\\)\S*(?=\s|") + let root: RegExpMatchArray | null = line.match(/(?<=@@\\|from\s\\)[\w|\\]*/); + if (root) { + let matches: RegExpMatchArray | null = line.split(/\s+/); + if (matches) { + let time: string = matches[0].toString(); + let username: string = matches[1].toString(); + let operation: string = matches[2].toString(); + let type: string = matches[3].toString(); + let delimiter: string[] = root.toString().split("\\"); + let seeker: HistoryData[] = datas; + delimiter.forEach((version, index) => { + let dataFound: HistoryData | undefined; + dataFound = seeker.find(data => data.version === version); + if (dataFound === undefined) { + + if (operation === 'checkout') { + seeker.push(lastData = { version: version, icon: '\u2713', username: username, operation: operation, type: type, time: time, data: [] }); + seeker = lastData.data; + } else { + seeker.push(lastData = { version: version, icon: '\u2937', username: username, operation: operation, type: type, time: time, data: [] }); + seeker = lastData.data; + } + } else { + if (index === delimiter.length - 1) { + switch (type) { + case 'version': + if (dataFound.operation === 'checkout') { + seeker.push(lastData = { version: version, icon: '\u2937', username: username, operation: operation, type: type, time: time, data: [] }); + } + break; + case 'branch': + dataFound.data.push(lastData = { version: version, icon: '\u002B', username: username, operation: operation, type: type, time: time, data: [] }); + break; } - break; - case 'branch': - dataFound.data.push(lastData = { version: version , icon:'\u002B' , username:username , operation:operation, type:type , time:time, data: [] }); - break; + } + seeker = dataFound.data; } + }); + if (seeker && type === 'branch') { + //seeker.push({ version: delimiter[delimiter.length - 1] , username:username , operation:operation, type:type , time:time, data: [] }); } - seeker = dataFound.data; } - }); - if (seeker && type === 'branch') { - //seeker.push({ version: delimiter[delimiter.length - 1] , username:username , operation:operation, type:type , time:time, data: [] }); + } else { + cclog.appendLine(line); } + } else { + lastData.comment = line; } - } else { - cclog.appendLine(line); - } - }else{ - lastData.comment = line; - } - }); - - /* - datas.forEach(element1 => { - cclog.appendLine(element1.title + " > "); - element1.data.forEach(element2 => { - cclog.appendLine("\t" + element2.title + " > "); - element2.data.forEach(element3 => { - cclog.appendLine("\t\t" + element3.title + " > "); - element3.data.forEach(element4 => { - cclog.appendLine("\t\t\t" + element4.title + " > "); - element4.data.forEach(element5 => { - cclog.appendLine("\t\t\t\t" + element5.title + " - "); - }); - }); }); + + + historyProvider.fetchHistory(datas); }); }); - */ - historyProvider.fetchHistory(datas); - }); + } else { + setContextCriteria(FileState.Unknown); + fileState.hide(); + fileStatus.hide(); + viewStatus.hide(); + } }));