Skip to content

Commit

Permalink
ZETA-9187: benchmark progress towards completing
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieGreenman committed Oct 7, 2024
1 parent 1a72dee commit cf4a78d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const COMMAND_TRY_TO_AUTH = 'extension.tryToAuth';
export const COMMAND_CONNECT_PROJECTS_TRY_TO_AUTH = 'extension.connectProjectsTryToAuth';
export const COMMAND_LOG_OUT_USER = 'extension.logoutUser';
export const COMMAND_CREATE_PROJECT = 'extension.createProject';
export const COMMAND_SHOW_RAZROO_DOCUMENTATION = 'extension.showRazrooDocumentation';

export const AUTH0_URL = "id.razroo.com";
export const AUTH0_CLIENT_ID = 'A0tLRYYfyGGtwyC4odVh50jmUZKW8bVJ';
Expand Down
41 changes: 41 additions & 0 deletions src/documentation/documentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as vscode from 'vscode';
import { exec } from 'child_process';
import { promisify } from 'util';

const execAsync = promisify(exec);

export async function getGitHistoryAndNavigateToRazrooUrl() {
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showErrorMessage('No active editor found.');
return;
}

const document = editor.document;
const filePath = document.uri.fsPath;
const lineNumber = editor.selection.active.line + 1;

try {
// Get Git blame information
const { stdout: blameOutput } = await execAsync(`git blame -L ${lineNumber},${lineNumber} "${filePath}"`);
const commitHash = blameOutput.split(' ')[0];

// Get commit details
const { stdout: commitDetails } = await execAsync(`git show --format="%B" -s ${commitHash}`);

// Extract URL from commit message
const urlMatch = commitDetails.match(/https?:\/\/razroo\.com\S+/);
if (!urlMatch) {
vscode.window.showInformationMessage('No Razroo URL found in the commit message.');
return;
}

const url = urlMatch[0];

// Open URL in default browser
vscode.env.openExternal(vscode.Uri.parse(url));

} catch (error: any) {
vscode.window.showErrorMessage(`Error: ${error.message}`);
}
}
18 changes: 17 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
RAZROO_PREVIEW_STATE,
MEMENTO_RAZROO_ORG_ID,
COMMAND_CREATE_PROJECT,
EMPTY
EMPTY,
COMMAND_SHOW_RAZROO_DOCUMENTATION
} from './constants';
import { EventEmitter } from 'stream';
import { pushScaffoldCommands } from './utils/scaffold/push-scaffold-commands';
Expand All @@ -40,6 +41,7 @@ import { disconnectVsCodeInstance } from "./disconnect/disconnect.service";
import { generateVsCodeDownloadCode } from "./graphql/generate-code/generate-code.service";
import { saveFiles } from "./utils/utils";
import { createPathForStarterRepo } from "./starters/starter-utils";
import { getGitHistoryAndNavigateToRazrooUrl } from "./documentation/documentation";

// function to determine if production environment or not
function isProductionFunc(context: vscode.ExtensionContext): boolean {
Expand Down Expand Up @@ -162,6 +164,19 @@ export async function activate(context: vscode.ExtensionContext) {
}
);

const showRazrooDocumentationCommand = vscode.commands.registerCommand(
COMMAND_SHOW_RAZROO_DOCUMENTATION,
async() => {
try {
getGitHistoryAndNavigateToRazrooUrl();
console.log('show documentation called');
} catch (error) {
console.log('COMMAND_TRY_TO_AUTH ERROR');
console.error(error);
}
}
);

const createProject = vscode.commands.registerCommand(
COMMAND_CREATE_PROJECT,
async({path, projectName}) => {
Expand Down Expand Up @@ -269,6 +284,7 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(logout);
context.subscriptions.push(logoutUser);
context.subscriptions.push(buildPreviewAndUploadDisposable);
context.subscriptions.push(showRazrooDocumentationCommand);


// execute command for tryToAuth to re-connect previously connected projects
Expand Down

0 comments on commit cf4a78d

Please sign in to comment.