-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patch for buildkit to fetch by commit
- Loading branch information
Showing
5 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Description: try fetching by commit, then regular fall back to deeper fetching | ||
Forwarded: no | ||
|
||
diff --git a/source/git/source.go b/source/git/source.go | ||
index d139942fc..700982bd6 100644 | ||
--- a/source/git/source.go | ||
+++ b/source/git/source.go | ||
@@ -459,6 +459,12 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out | ||
// skip fetch if commit already exists | ||
if _, err := git.Run(ctx, "cat-file", "-e", ref+"^{commit}"); err == nil { | ||
doFetch = false | ||
+ } else { | ||
+ // try fetching commit directly | ||
+ // TODO limit to known working git hosts? | ||
+ if _, err := git.Run(ctx, "fetch", "origin", ref+":"); err == nil { | ||
+ doFetch = false | ||
+ } | ||
} | ||
} | ||
|