Skip to content

Commit c0ea7d7

Browse files
committed
feat: Add contributor info
1 parent 827c070 commit c0ea7d7

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/bin/flipflag.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

4361
function 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

274293
Behavior:
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.

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"noEmitOnError": true,
88
"strict": true,
99
"esModuleInterop": false,
10+
"allowSyntheticDefaultImports": true,
1011
"declaration": true,
1112
"outDir": "out-tsc",
1213
"rootDir": "./",

0 commit comments

Comments
 (0)