Skip to content

Commit 6e5b4c7

Browse files
committed
[content-init] If re-applying stashed changes from an unclean prebuild after checkout fails, throw them away instead of leaving merge conflicts in the workspace
1 parent 2365ba4 commit 6e5b4c7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

components/content-service/pkg/initializer/prebuild.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ func (p *PrebuildInitializer) Run(ctx context.Context, mappings []archive.IDMapp
110110
// If any of these cleanup operations fail that's no reason to fail ws initialization.
111111
// It just results in a slightly degraded state.
112112
if didStash {
113-
_ = p.Git.Git(ctx, "stash", "pop")
113+
err = p.Git.Git(ctx, "stash", "pop")
114+
if err != nil {
115+
// If restoring the stashed changes produces merge conflicts on the new Git ref, simply
116+
// throw them away (they'll remain in the stash, but are likely outdated anyway).
117+
_ = p.Git.Git(ctx, "reset", "--hard")
118+
}
114119
}
115120

116121
log.Debug("prebuild initializer Git operations complete")

0 commit comments

Comments
 (0)