File tree Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -68,10 +68,8 @@ docker.io/%:
68
68
69
69
.PHONY : checkout
70
70
checkout : src
71
- @git -C src/github.com/opencontainers/runc fetch --depth 1 origin " $( RUNC_REF) "
72
- @git -C src/github.com/opencontainers/runc checkout -q FETCH_HEAD
73
- @git -C src/github.com/containerd/containerd fetch --depth 1 origin " $( REF) "
74
- @git -C src/github.com/containerd/containerd checkout -q FETCH_HEAD
71
+ ./scripts/checkout.sh src/github.com/opencontainers/runc " $( RUNC_REF) "
72
+ ./scripts/checkout.sh src/github.com/containerd/containerd " $( REF) "
75
73
76
74
.PHONY : build
77
75
build : checkout
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env sh
2
+
3
+ # Copyright 2018-2020 Docker Inc.
4
+
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ checkout () (
18
+ set -ex
19
+ SRC=" $1 "
20
+ REF=" $2 "
21
+ REF_FETCH=" $REF "
22
+ # if ref is branch or tag, retrieve its canonical form
23
+ REF=$( git -C " $SRC " ls-remote --refs --heads --tags origin " $REF " | awk ' {print $2}' )
24
+ if [ -n " $REF " ]; then
25
+ # if branch or tag then create it locally too
26
+ REF_FETCH=" $REF :$REF "
27
+ else
28
+ REF=" FETCH_HEAD"
29
+ fi
30
+ git -C " $SRC " fetch --depth 1 origin " $REF_FETCH "
31
+ git -C " $SRC " checkout -q " $REF "
32
+ )
33
+
34
+
35
+ # Only execute checkout function above if this file is executed, not sourced from another script
36
+ prog=checkout.sh # needs to be in sync with this file's name
37
+ if [ " $( basename -- $0 ) " = " $prog " ]; then
38
+ checkout $*
39
+ fi
You can’t perform that action at this time.
0 commit comments