@@ -17,15 +17,16 @@ const getGitStatus = async (repoPath) => {
17
17
} ;
18
18
19
19
let gitRemoteData = "" ;
20
- let gitBranchList = [ ] ;
20
+ let gitBranchList = [ "NO_BRANCHES" ] ;
21
21
let gitCurrentBranch = errorStatus . noActiveBranch ;
22
22
let gitRemoteHost = "" ;
23
23
let gitRepoName = "" ;
24
24
let gitTotalCommits = "" ;
25
25
let gitLatestCommit = "" ;
26
26
let gitTrackedFiles = "" ;
27
27
let gitTotalTrackedFiles = 0 ;
28
- let gitAllBranchList = [ ] ;
28
+ let gitAllBranchList = [ "NO_BRANCHES" ] ;
29
+ let isGitLogAvailable = false ;
29
30
30
31
const gitRemoteReference = [
31
32
"github" ,
@@ -37,18 +38,21 @@ const getGitStatus = async (repoPath) => {
37
38
38
39
const currentDir = `cd ${ repoPath } ;` ;
39
40
40
- let isGitLogAvailable = fs . promises
41
+ isGitLogAvailable = await fs . promises
41
42
. access ( `${ repoPath } /.git/logs` )
42
43
. then ( ( ) => {
43
44
isGitLogAvailable = true ;
44
45
return isGitLogAvailable ;
45
46
} )
46
47
. catch ( ( err ) => {
47
- console . log ( err ) ;
48
+ console . log ( "Not a git repo or a new git repo with no commits!" ) ;
49
+ // console.log(err);
48
50
isGitLogAvailable = false ;
49
51
return isGitLogAvailable ;
50
52
} ) ;
51
53
54
+ console . log ( "Git log available : " , isGitLogAvailable ) ;
55
+
52
56
// Module to get git remote repo URL
53
57
54
58
let gitRemotePromise =
@@ -148,6 +152,7 @@ const getGitStatus = async (repoPath) => {
148
152
} ) ) ;
149
153
150
154
gitBranchList =
155
+ isGitLogAvailable &&
151
156
gitBranchList . length > 0 &&
152
157
gitBranchList
153
158
. split ( "\n" )
@@ -160,12 +165,22 @@ const getGitStatus = async (repoPath) => {
160
165
} )
161
166
. filter ( ( entry ) => ( entry !== "" ? entry : null ) ) ;
162
167
163
- if ( gitCurrentBranch . length > 0 && gitCurrentBranch !== "No Active Branch" ) {
168
+ if (
169
+ isGitLogAvailable &&
170
+ gitCurrentBranch . length > 0 &&
171
+ gitCurrentBranch !== "No Active Branch"
172
+ ) {
164
173
gitBranchList = [ gitCurrentBranch , ...gitBranchList ] ;
165
174
} else {
166
175
gitBranchList = errorStatus . noBranch ;
167
176
}
168
177
178
+ if ( ! gitBranchList && gitBranchList . length === 0 ) {
179
+ gitBranchList = errorStatus . noBranch ;
180
+ }
181
+
182
+ console . log ( "GIT BRANCH LIST" , gitBranchList ) ;
183
+
169
184
// Module to get total number of commits to current branch
170
185
isGitLogAvailable &&
171
186
( await execPromised ( `git log --oneline` , {
0 commit comments