Skip to content

cu checkout#108

Merged
cwlbraa merged 3 commits into
mainfrom
cu-checkout
Jun 23, 2025
Merged

cu checkout#108
cwlbraa merged 3 commits into
mainfrom
cu-checkout

Conversation

@aluzzardi
Copy link
Copy Markdown
Contributor

@aluzzardi aluzzardi commented Jun 19, 2025

  • Do not set up remote tracking branches for each environment anymore
  • Instead, provide an explicit cu checkout command that does that
  • Similar to gh pr checkout

This still requires reworking the prompt engineering behind the scenes

DEPENDS ON #107

Comment thread repository/repository.go Outdated
Comment on lines +214 to +226
// set up remote tracking branch if it's not already there
_, err := runGitCommand(ctx, r.userRepoPath, "show-ref", "--verify", "--quiet", fmt.Sprintf("refs/heads/%s", branch))
if err != nil {
_, err = runGitCommand(ctx, r.userRepoPath, "branch", "--track", branch, fmt.Sprintf("%s/%s", containerUseRemote, id))
if err != nil {
return "", err
}
}

_, err = runGitCommand(ctx, r.userRepoPath, "checkout", branch)
Copy link
Copy Markdown
Contributor

@cwlbraa cwlbraa Jun 20, 2025

Choose a reason for hiding this comment

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

i think this impl might be overcomplicating things. do we get correct behavior with just plain git checkout $branch? maybe with a fetch thrown in? iirc the show-ref and branch --track wackiness was only necessary because I wanted the branch setup entirely in the background, and i only wanted to touch it if the user hadn't already done stuff with it. in this context, the user is doing things themselves, so we can be way less sneaky if we'd like to.

also, we should make sure this command always tries to get the latest possible remote state, maybe erroring if the user has conflicts/untracked work?

Comment thread repository/repository.go
return nil
}

func (r *Repository) Checkout(ctx context.Context, id string) (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this makes me wanna have a separate UserRepository type...

in my head the ideal Repository is centered around the remote, whereas this method is way more centered around the UserRepository.

@cwlbraa
Copy link
Copy Markdown
Contributor

cwlbraa commented Jun 23, 2025

i'm taking this

Signed-off-by: Andrea Luzzardi <andrea@luzzardi.com>
cwlbraa added 2 commits June 23, 2025 14:05
Signed-off-by: Connor Braa <connor@dagger.io>
Signed-off-by: Connor Braa <connor@dagger.io>
@cwlbraa
Copy link
Copy Markdown
Contributor

cwlbraa commented Jun 23, 2025

fixed up prompt engineering and added logic to git merge --ff-only when the remote has commits you don't have. this logic prevents the cu checkout command from checking out old work after environement_open.

@cwlbraa cwlbraa self-requested a review June 23, 2025 21:57
@cwlbraa cwlbraa marked this pull request as ready for review June 23, 2025 21:57
@aluzzardi
Copy link
Copy Markdown
Contributor Author

LGTM

@cwlbraa cwlbraa merged commit 7c60136 into main Jun 23, 2025
1 check passed
@aluzzardi aluzzardi deleted the cu-checkout branch June 26, 2025 20:26
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.

2 participants