File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as vscode from "vscode" ;
22import * as utils from "./utils" ;
3- import * as path from "path" ;
3+ // ...existing code...
44import getJiraDiagnostics from "./jira" ;
55
66const preferSubjectLineLength = 50 ;
@@ -35,7 +35,7 @@ export function getDiagnostics(doc: vscode.TextDocument): vscode.Diagnostic[] {
3535 returnMe . push ( ...getSecondLineDiagnostic ( secondLine ) ) ;
3636 }
3737
38- if ( path . basename ( doc . fileName ) === "COMMIT_EDITMSG" ) {
38+ if ( utils . basename ( doc . fileName ) === "COMMIT_EDITMSG" ) {
3939 returnMe . push ( ...getNoDiffDiagnostic ( doc ) ) ;
4040 }
4141
Original file line number Diff line number Diff line change 11import * as vscode from "vscode" ;
22import * as git from "./git" ;
3- import * as path from "path" ;
43import * as child_process from "child_process" ;
5- import * as util from "util" ;
4+ import * as nodeUtil from "util" ;
5+ import * as utils from "./utils" ;
66
7- const execFile = util . promisify ( child_process . execFile ) ;
7+ const execFile = nodeUtil . promisify ( child_process . execFile ) ;
88
99export default async function getCurrentGitBranch (
1010 docUri : vscode . Uri ,
@@ -65,7 +65,7 @@ async function getCurrentGitBranchFromGit(
6565 }
6666
6767 const docWithAbsolutePath = docUri . fsPath ;
68- const docDirectory = path . dirname ( docWithAbsolutePath ) ;
68+ const docDirectory = utils . dirname ( docWithAbsolutePath ) ;
6969
7070 try {
7171 const { stdout } = await execFile (
Original file line number Diff line number Diff line change 11import * as vscode from "vscode" ;
2- import * as path from "path" ;
32import * as verbosecommits from "./verbosecommits" ;
3+ import * as utils from "./utils" ;
44
55/** Show informational toast about doing verbose Git commits */
66export async function displayVerboseDiffMessage ( doc : vscode . TextDocument ) {
7- if ( path . basename ( doc . fileName ) !== "COMMIT_EDITMSG" ) {
7+ if ( utils . basename ( doc . fileName ) !== "COMMIT_EDITMSG" ) {
88 // We only like one kind of files
99 return ;
1010 }
Original file line number Diff line number Diff line change 11import * as vscode from "vscode" ;
2- import * as path from "path" ;
32import * as utils from "./utils" ;
43import { gitBranch , setVerboseCommitCommandId } from "./extension" ;
54import { createBranchIssueIdFix , createUpcaseJiraIdFix } from "./jira" ;
@@ -25,7 +24,7 @@ export default class GitCommitCodeActionProvider
2524 returnMe . push ( ...createBranchIssueIdFix ( gitBranch , doc , range ) ) ;
2625 returnMe . push ( ...createUpcaseJiraIdFix ( doc , range ) ) ;
2726
28- if ( path . basename ( doc . fileName ) === "COMMIT_EDITMSG" ) {
27+ if ( utils . basename ( doc . fileName ) === "COMMIT_EDITMSG" ) {
2928 returnMe . push ( ...( await createEnableGitVerboseCommitFix ( doc , range ) ) ) ;
3029 }
3130
Original file line number Diff line number Diff line change @@ -89,3 +89,26 @@ export function getJiraIssueIdFromBranchName(
8989
9090 return undefined ;
9191}
92+
93+ /**
94+ * Returns the last portion of a path, handling both / and \ separators.
95+ * Equivalent to Node's path.basename, but works in browser and cross-platform.
96+ * @param filePath - The full file path.
97+ * @returns The file name portion of the path.
98+ */
99+ export function basename ( filePath : string ) : string {
100+ const parts = filePath . split ( / [ / ] + / ) ;
101+ return parts . pop ( ) || "" ;
102+ }
103+
104+ /**
105+ * Returns the directory portion of a path, handling both / and \ separators.
106+ * Equivalent to Node's path.dirname, but works in browser and cross-platform.
107+ * @param filePath - The full file path.
108+ * @returns The directory portion of the path.
109+ */
110+ export function dirname ( filePath : string ) : string {
111+ const parts = filePath . split ( / [ / ] + / ) ;
112+ parts . pop ( ) ;
113+ return parts . join ( "/" ) ;
114+ }
You can’t perform that action at this time.
0 commit comments