Skip to content

reset the workspace before checkout - #24

Merged
xytan0056 merged 3 commits into
gitcleanfrom
gitreset
Feb 26, 2026
Merged

xytan0056 merged 3 commits into
gitcleanfrom
gitreset

Conversation

@xytan0056

Copy link
Copy Markdown
Contributor

before checkout to requested sha , clean up the ws just in case there are leftever files or corruptions

Test Plan

unit test
local tested

Issue

@xytan0056
xytan0056 marked this pull request as ready for review February 26, 2026 02:29
@xytan0056
xytan0056 requested review from a team as code owners February 26, 2026 02:29
if err := w.git.Reset(ctx); err != nil {
return fmt.Errorf("git reset --hard: %w", err)
}
if err := w.git.Clean(ctx); err != nil {

@xytan0056 xytan0056 Feb 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this potentially can be slow to delete, if there are folders like "bazel-out" or "pkg/mod/" stuff. But i see current TA does this too. And it's necessary if request is cancel in the middle of git checkout, repo is in a dirty state. We can try this out.
Another way is to delete the whole WS and ask repo manager to re-clone with --local. We can do this if clean -fdx is too slow
wdyt? @yushan8

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.

I think it'll helpful to benchmark the performance after and see which one is faster with reseting the workspace

if err := w.git.Reset(ctx); err != nil {
return fmt.Errorf("git reset --hard: %w", err)
}
if err := w.git.Clean(ctx); err != nil {

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.

I think it'll helpful to benchmark the performance after and see which one is faster with reseting the workspace

@xytan0056
xytan0056 merged commit 0963559 into gitclean Feb 26, 2026
1 check passed
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