-
Notifications
You must be signed in to change notification settings - Fork 16
feat(branching): Add branching #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR adds branching support to the translation system, enabling branch-specific translation management. The implementation includes git branch auto-detection, API endpoints for branch operations, and a workflow-based architecture using step classes.
Key changes:
- New git branch detection utilities (
getCurrentBranch,getIncomingBranches,getCheckedOutBranches) - API endpoints for creating branches (
createBranch) and querying branch data (queryBranchData) - Workflow steps:
BranchStep,UploadStep,EnqueueStep,PollJobsStep,DownloadStep - Branch-aware file upload and translation tracking with
branchId,incomingBranchId, andcheckedOutBranchIdfields - CLI flags:
--branch,--enable-branching,--disable-branch-detection - Batch processing utilities for handling large API requests
Critical issues:
- Two
execAsynccalls pass full git commands as strings instead of separating command and arguments, causing execution failures
Confidence Score: 2/5
- This PR has critical syntax errors that will cause runtime failures in branch detection functionality
- The git command execution in
branches.tsuses incorrectexecAsyncsyntax that will cause failures when branch detection is enabled. TheexecAsyncwrapper expects command and arguments separately (likeexecFile), but lines 46-50 and 106-108 pass the entire command as a single string. This will prevent the branching feature from working correctly. - packages/cli/src/git/branches.ts requires immediate fixes to the
execAsynccalls before this PR can be safely merged
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/cli/src/git/branches.ts | 2/5 | Added git branch detection functions with incorrect execAsync usage causing command execution failures |
| packages/cli/src/workflow/BranchStep.ts | 4/5 | Implemented branch resolution workflow step with proper error handling and fallback to default branch |
| packages/core/src/translate/createBranch.ts | 4/5 | Added API endpoint for branch creation with minor redundant Math.min usage |
| packages/core/src/translate/queryBranchData.ts | 4/5 | Added API endpoint for querying branch information with minor redundant Math.min usage |
| packages/cli/src/workflow/UploadStep.ts | 5/5 | Updated upload workflow to include branch data and optimize file uploads by checking existing files |
| packages/core/src/translate/uploadSourceFiles.ts | 5/5 | Updated to support branching by adding incomingBranchId and checkedOutBranchId fields |
Sequence Diagram
sequenceDiagram
participant CLI as CLI Command
participant BranchStep as BranchStep
participant Git as Git Operations
participant API as GT API
participant UploadStep as UploadStep
participant EnqueueStep as EnqueueStep
participant PollStep as PollJobsStep
CLI->>BranchStep: Start workflow
alt Branch detection enabled
BranchStep->>Git: getCurrentBranch()
Git-->>BranchStep: current branch info
BranchStep->>Git: getIncomingBranches()
Git-->>BranchStep: merged branch list
BranchStep->>Git: getCheckedOutBranches()
Git-->>BranchStep: checkout history
end
BranchStep->>API: queryBranchData(branchNames)
API-->>BranchStep: existing branch data
alt Branch doesn't exist
BranchStep->>API: createBranch(name, isDefault)
API-->>BranchStep: new branch created
end
BranchStep-->>UploadStep: branch data resolved
UploadStep->>API: queryFileData(files, branchId)
API-->>UploadStep: existing file status
UploadStep->>API: uploadSourceFiles(files, branchIds)
API-->>UploadStep: uploaded file references
UploadStep-->>EnqueueStep: file references
EnqueueStep->>API: enqueueFiles(files, locales)
API-->>EnqueueStep: job IDs
EnqueueStep-->>PollStep: job data
loop Poll every 5 seconds
PollStep->>API: checkJobStatus(jobIds)
API-->>PollStep: job status updates
PollStep->>PollStep: update progress
end
PollStep-->>CLI: translation complete
92 files reviewed, 4 comments
packages/cli/src/git/branches.ts
Outdated
| const { stdout: reflog } = await execAsync('git reflog --format="%gs"', { | ||
| encoding: 'utf8', | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: execAsync expects command and args separately, but receiving full command as string
| const { stdout: reflog } = await execAsync('git reflog --format="%gs"', { | |
| encoding: 'utf8', | |
| }); | |
| const { stdout: reflog } = await execAsync( | |
| 'git', | |
| ['reflog', '--format=%gs'], | |
| { | |
| encoding: 'utf8', | |
| } | |
| ); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/git/branches.ts
Line: 106:108
Comment:
**syntax:** `execAsync` expects command and args separately, but receiving full command as string
```suggestion
const { stdout: reflog } = await execAsync(
'git',
['reflog', '--format=%gs'],
{
encoding: 'utf8',
}
);
```
How can I resolve this? If you propose a fix, please make it concise.| query: CreateBranchQuery, | ||
| config: TranslationRequestConfig | ||
| ): Promise<CreateBranchResult> { | ||
| const timeout = Math.min(maxTimeout, maxTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Math.min(maxTimeout, maxTimeout) is redundant
| const timeout = Math.min(maxTimeout, maxTimeout); | |
| const timeout = maxTimeout; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/src/translate/createBranch.ts
Line: 29:29
Comment:
**style:** `Math.min(maxTimeout, maxTimeout)` is redundant
```suggestion
const timeout = maxTimeout;
```
How can I resolve this? If you propose a fix, please make it concise.| query: BranchQuery, | ||
| config: TranslationRequestConfig | ||
| ): Promise<BranchDataResult> { | ||
| const timeout = Math.min(maxTimeout, maxTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Math.min(maxTimeout, maxTimeout) is redundant
| const timeout = Math.min(maxTimeout, maxTimeout); | |
| const timeout = maxTimeout; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/src/translate/queryBranchData.ts
Line: 25:25
Comment:
**style:** `Math.min(maxTimeout, maxTimeout)` is redundant
```suggestion
const timeout = maxTimeout;
```
How can I resolve this? If you propose a fix, please make it concise.|
@greptileai roast this guy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this PR, I can see some... interesting choices here. Let me break down what's happening:
The Good (surprisingly)
- Actually added proper error handling for malformed JSON/YAML files instead of just crashing
- The branching logic is more sophisticated than I expected
- Test updates are consistent with the changes
The Questionable
- That random "wtf" comment in
packages/cli/src/workflow/stage.tsline 87. Really? That's what we're shipping to production? 🤦♂️ - Disabled caching for
build:cleanin turbo.json - someone clearly gave up on making the build system work properly - The branch detection logic went from simple to overly complex. Now we're parsing git logs with regex instead of using proper git commands
The Bad
- 50 files changed for "Add branching"? This feels like 3 different PRs mashed together
- Version bumps across the entire monorepo for what should be a targeted feature
- The PR body is literally
null- zero effort in explaining what this actually does - Mixing feature work with dependency updates and build system changes
The Ugly
// wtfThis comment right before the user edit diffs step tells me someone was debugging and forgot to clean up. Professional stuff right there.
The fact that you're asking me to "roast this guy" when you could have just written a proper PR description and cleaned up your debug comments is... chef's kiss.
At least the tests pass, I guess? 🤷♂️
ErnestM1234
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changset? lol
|
|
||
| if (parallel) { | ||
| // Process all batches in parallel | ||
| const results = await Promise.all(batches.map((batch) => processor(batch))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want batch behavior to fail for all if a single batch operation fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah the user / client should handle retry / failures
fernando-aviles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
No description provided.