1
1
import * as fs from 'fs' ;
2
2
import * as path from 'path' ;
3
- import * as child_process from 'child_process' ;
4
3
5
4
import { scip } from './scip' ;
6
5
import { diffSnapshot , formatSnapshot , writeSnapshot } from './lib' ;
@@ -24,39 +23,23 @@ function indexAction(options: IndexOptions): void {
24
23
const projectRoot = workspaceRoot ;
25
24
process . chdir ( workspaceRoot ) ;
26
25
27
- // TODO: use setup.py / poetry to determine better projectName
28
- const projectName = options . projectName ;
29
-
30
- // TODO: Use setup.py / poetry to determine better projectVersion
31
- // for now, the current hash works OK
32
- let projectVersion = options . projectVersion ;
33
- if ( ! projectVersion || projectVersion === '' ) {
34
- // Default to current git hash
35
- try {
36
- projectVersion = child_process . execSync ( 'git rev-parse HEAD' ) . toString ( ) . trim ( ) ;
37
- } catch ( e ) {
38
- projectVersion = '' ;
39
- }
40
- }
41
-
42
26
const outputFile = path . join ( projectRoot , options . output ) ;
43
27
const output = fs . openSync ( outputFile , 'w' ) ;
44
28
45
- sendStatus ( `Indexing ${ projectRoot } with version ${ projectVersion } ` ) ;
46
-
47
29
try {
48
30
let indexer = new Indexer ( {
49
31
...options ,
50
32
workspaceRoot,
51
33
projectRoot,
52
- projectName,
53
- projectVersion,
54
34
environment,
35
+ infer : { projectVersionFromCommit : true } ,
55
36
writeIndex : ( partialIndex : scip . Index ) : void => {
56
37
fs . writeSync ( output , partialIndex . serializeBinary ( ) ) ;
57
38
} ,
58
39
} ) ;
59
40
41
+ sendStatus ( `Indexing ${ projectRoot } with version ${ indexer . scipConfig . projectVersion } ` ) ;
42
+
60
43
indexer . index ( ) ;
61
44
} catch ( e ) {
62
45
console . warn (
@@ -95,8 +78,6 @@ function snapshotAction(snapshotRoot: string, options: SnapshotOptions): void {
95
78
}
96
79
97
80
console . log ( '... Snapshotting ... ' ) ;
98
- const projectName = options . projectName ;
99
- const projectVersion = options . projectVersion ;
100
81
const environment = options . environment ? path . resolve ( options . environment ) : undefined ;
101
82
102
83
const snapshotOnly = options . only ;
@@ -127,9 +108,8 @@ function snapshotAction(snapshotRoot: string, options: SnapshotOptions): void {
127
108
...options ,
128
109
workspaceRoot : projectRoot ,
129
110
projectRoot,
130
- projectName,
131
- projectVersion,
132
111
environment,
112
+ infer : { projectVersionFromCommit : false } ,
133
113
writeIndex : ( partialIndex : any ) : void => {
134
114
fs . writeSync ( output , partialIndex . serializeBinary ( ) ) ;
135
115
} ,
0 commit comments