Skip to content

Commit 3f04851

Browse files
aaronshafclaude
andcommitted
fix(ji-do): fix Effect composition bug in ensureSingleCommitForGerrit
Critical bug fix: The squashing logic was not executing due to incorrect Effect composition. The Problem: - ensureSingleCommitForGerrit was using Effect.sync() that returned Effect.runSync() for the squashing case - This caused the inner Effect to never execute - Result: Multiple commits were pushed to Gerrit without being squashed The Fix: - Restructured to use proper Effect.flatMap composition - First Effect.sync() counts commits and returns the count - Then Effect.flatMap() conditionally calls squashCommitsForGerrit - Now the squashing Effect actually executes when needed Flow: 1. Check if remote is Gerrit (early return if not) 2. Count commits via Effect.sync() 3. Use Effect.flatMap() to conditionally squash if count > 1 4. squashCommitsForGerrit Effect executes properly This ensures that when ji do creates multiple commits during iterations, they will be automatically squashed into one before pushing to Gerrit. Testing: - All 502 tests pass - TypeScript compilation succeeds - Effect composition is now correct 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3e91613 commit 3f04851

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

src/cli/commands/do-publish.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,35 @@ const squashCommitsForGerrit = (workingDirectory: string, commitCount: number):
108108
const ensureSingleCommitForGerrit = (
109109
workingDirectory: string,
110110
remoteType: RemoteType,
111-
): Effect.Effect<void, DoCommandError> =>
112-
Effect.sync(() => {
113-
if (remoteType !== 'gerrit') {
114-
return; // Only enforce for Gerrit
115-
}
111+
): Effect.Effect<void, DoCommandError> => {
112+
if (remoteType !== 'gerrit') {
113+
return Effect.void; // Only enforce for Gerrit
114+
}
116115

116+
return Effect.sync(() => {
117117
const commitCount = countCommitsSinceBase(workingDirectory);
118118

119119
if (commitCount === 0) {
120120
console.log(chalk.yellow('⚠️ No commits found - nothing to publish'));
121-
return;
121+
return commitCount;
122122
}
123123

124124
if (commitCount === 1) {
125125
console.log(chalk.green('✅ Exactly 1 commit found - ready for Gerrit'));
126-
return;
126+
return commitCount;
127127
}
128128

129129
// Multiple commits found - need to squash
130-
return Effect.runSync(squashCommitsForGerrit(workingDirectory, commitCount));
131-
});
130+
return commitCount;
131+
}).pipe(
132+
Effect.flatMap((commitCount) => {
133+
if (commitCount > 1) {
134+
return squashCommitsForGerrit(workingDirectory, commitCount);
135+
}
136+
return Effect.void;
137+
}),
138+
);
139+
};
132140

133141
/**
134142
* Executes the configured publish command from .jiconfig.json

0 commit comments

Comments
 (0)