Skip to content

Commit

Permalink
Merge pull request #16624 from bparees/idempotent_init
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Wipe out any existing content in the workdir before cloning
  • Loading branch information
openshift-merge-robot committed Sep 30, 2017
2 parents 43917de + f0f7ce9 commit bd5b800
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/build/builder/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ func (e gitNotFoundError) Error() string {

// GitClone clones the source associated with a build(if any) into the specified directory
func GitClone(ctx context.Context, gitClient GitClient, gitSource *buildapi.GitBuildSource, revision *buildapi.SourceRevision, dir string) (*git.SourceInfo, error) {

// It is possible for the initcontainer to get restarted, thus we must wipe out the directory if it already exists.
err := os.RemoveAll(dir)
if err != nil {
return nil, err
}
os.MkdirAll(dir, 0777)

hasGitSource, err := extractGitSource(ctx, gitClient, gitSource, revision, dir, initialURLCheckTimeout)
Expand Down

0 comments on commit bd5b800

Please sign in to comment.