Skip to content

Conversation

@brian-lou
Copy link
Contributor

No description provided.

@brian-lou brian-lou marked this pull request as ready for review November 7, 2025 02:33
@brian-lou brian-lou requested a review from a team as a code owner November 7, 2025 02:33
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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, and checkedOutBranchId fields
  • CLI flags: --branch, --enable-branching, --disable-branch-detection
  • Batch processing utilities for handling large API requests

Critical issues:

  • Two execAsync calls 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.ts uses incorrect execAsync syntax that will cause failures when branch detection is enabled. The execAsync wrapper expects command and arguments separately (like execFile), 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 execAsync calls 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
Loading

92 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 106 to 108
const { stdout: reflog } = await execAsync('git reflog --format="%gs"', {
encoding: 'utf8',
});
Copy link
Contributor

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

Suggested change
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);
Copy link
Contributor

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

Suggested change
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);
Copy link
Contributor

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

Suggested change
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.

@ErnestM1234
Copy link
Contributor

@greptileai roast this guy

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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.ts line 87. Really? That's what we're shipping to production? 🤦‍♂️
  • Disabled caching for build:clean in 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

// wtf

This 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? 🤷‍♂️

Copy link
Contributor

@ErnestM1234 ErnestM1234 left a 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)));
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

@fernando-aviles fernando-aviles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@brian-lou brian-lou merged commit fee5d4a into main Nov 11, 2025
15 checks passed
@brian-lou brian-lou deleted the b/branching branch November 11, 2025 02:05
@github-actions github-actions bot mentioned this pull request Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants