@@ -8,22 +8,20 @@ export async function getEditFilePath(
8
8
top : string ,
9
9
edit ?: boolean | string
10
10
) : Promise < string > {
11
- let editFilePath : string ;
12
11
if ( typeof edit === 'string' ) {
13
- editFilePath = path . resolve ( top , edit ) ;
14
- } else {
15
- const dotgitPath = path . join ( top , '.git' ) ;
16
- const dotgitStats : Stats = sander . lstatSync ( dotgitPath ) ;
17
- if ( dotgitStats . isDirectory ( ) ) {
18
- editFilePath = path . join ( top , '.git/COMMIT_EDITMSG' ) ;
19
- } else {
20
- const gitFile : string = await sander . readFile ( dotgitPath , {
21
- encoding : 'utf-8'
22
- } ) ;
23
- const relativeGitPath = gitFile . replace ( 'gitdir: ' , '' ) . replace ( '\n' , '' ) ;
24
- editFilePath = path . resolve ( top , relativeGitPath , 'COMMIT_EDITMSG' ) ;
25
- }
12
+ return path . resolve ( top , edit ) ;
26
13
}
27
14
28
- return editFilePath ;
15
+ const dotgitPath = path . join ( top , '.git' ) ;
16
+ const dotgitStats : Stats = sander . lstatSync ( dotgitPath ) ;
17
+
18
+ if ( dotgitStats . isDirectory ( ) ) {
19
+ return path . join ( top , '.git/COMMIT_EDITMSG' ) ;
20
+ }
21
+
22
+ const gitFile : string = await sander . readFile ( dotgitPath , {
23
+ encoding : 'utf-8'
24
+ } ) ;
25
+ const relativeGitPath = gitFile . replace ( 'gitdir: ' , '' ) . replace ( '\n' , '' ) ;
26
+ return path . resolve ( top , relativeGitPath , 'COMMIT_EDITMSG' ) ;
29
27
}
0 commit comments