@@ -105,9 +105,9 @@ export interface GitInfo {
105105 */
106106function isGitRepo ( directory : string = process . cwd ( ) ) : boolean {
107107 try {
108- // Check if .git directory exists or if git rev-parse succeeds
109- execSync ( 'git rev-parse --is-inside-work-tree' , { cwd : directory , encoding : 'utf-8' , stdio : 'ignore' } ) ;
110- return true ;
108+ // Check if .git directory exists
109+ const gitDir = path . join ( directory , '.git' ) ;
110+ return fs . existsSync ( gitDir ) && fs . lstatSync ( gitDir ) . isDirectory ( ) ;
111111 } catch ( error ) {
112112 return false ;
113113 }
@@ -127,16 +127,16 @@ export function getGitInfo(directory: string = process.cwd()): GitInfo {
127127 error : "Telemetry disabled"
128128 } ;
129129 }
130-
131- // First check if this is a git repository
132- if ( ! isGitRepo ( directory ) ) {
133- return {
134- uncommittedChanges : false ,
135- error : "Not a git repository"
136- } ;
137- }
138130
139131 try {
132+ // First check if this is a git repository
133+ if ( ! isGitRepo ( directory ) ) {
134+ return {
135+ uncommittedChanges : false ,
136+ error : "Not a git repository"
137+ } ;
138+ }
139+
140140 const commitHash = execSync ( 'git rev-parse HEAD' , { cwd : directory , encoding : 'utf-8' } ) . trim ( ) ;
141141 const branch = execSync ( 'git rev-parse --abbrev-ref HEAD' , { cwd : directory , encoding : 'utf-8' } ) . trim ( ) ;
142142 const repoUrl = execSync ( 'git config --get remote.origin.url' , { cwd : directory , encoding : 'utf-8' } ) . trim ( ) . replace ( / \. g i t $ / , '' ) ;
@@ -395,16 +395,6 @@ export class HoneyHiveTracer {
395395 sessionId : this . sessionId
396396 }
397397 } ;
398-
399- // Gather git information
400- const gitInfo = getGitInfo ( ) ;
401-
402- // Only add git info to metadata if there's no error
403- if ( ! gitInfo . error && requestBody . session ) {
404- requestBody . session . metadata = {
405- git : gitInfo
406- } ;
407- }
408398
409399 if ( ! HoneyHiveTracer . sdkInstance ) {
410400 throw new Error ( "SDK instance is not initialized" ) ;
0 commit comments