@@ -38,6 +38,24 @@ function saveTasks(tasks: Tasks) {
3838 fs . writeFileSync ( TASKS_FILE , yamlStr , 'utf8' ) ;
3939}
4040
41+ // ==== git helpers ====
42+
43+ function getGitEmail ( ) : string {
44+ try {
45+ const email = execSync ( 'git config user.email' , {
46+ stdio : [ 'ignore' , 'pipe' , 'ignore' ] ,
47+ } )
48+ . toString ( )
49+ . trim ( ) ;
50+
51+ if ( email ) return email ;
52+ } catch {
53+ // ignore, fallback below
54+ }
55+
56+ return process . env . FLIPFLAG_USER || '' ;
57+ }
58+
4159// ==== git branches logic ====
4260
4361function createBranchIfNeeded ( taskId : string , type : TaskType ) {
@@ -151,14 +169,15 @@ async function cmdStart(argv: string[]) {
151169 if (!tasks[taskId]) {
152170 tasks[taskId] = {
153171 description: '',
154- contributor : process . env . FLIPFLAG_USER || '' ,
172+ contributor: getGitEmail() ,
155173 type,
156174 times: [],
157175 };
158176 console.log(` Creating new task ${taskId } `);
159177 } else {
160178 // if task already exists, we can update type if it's empty
161179 if (!tasks[taskId].type) tasks[taskId].type = type;
180+ if (!tasks[taskId].contributor) tasks[taskId].contributor = getGitEmail();
162181 console.log(` Continuing work on task ${taskId } `);
163182 }
164183
@@ -272,6 +291,7 @@ Usage:
272291 flipflag stop [ TASK - ID ]
273292
274293Behavior :
294+ - contributor is taken from "git config user.email" ( fallback : FLIPFLAG_USER env or empty string )
275295 - If time tracking is enabled , "start" will keep running and wait until you press Enter ,
276296 then it will set "finished" for the last interval .
277297 - If time tracking is disabled , "start" behaves as a simple task initializer and exits immediately .
0 commit comments