Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
e6554181
Commit
e6554181
authored
8 years ago
by
Kaspar Schleiser
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dist: tools: bump git-cache version (#6217)
parent
0bab8c0d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dist/tools/git/README.md
+5
-1
5 additions, 1 deletion
dist/tools/git/README.md
dist/tools/git/git-cache
+40
-4
40 additions, 4 deletions
dist/tools/git/git-cache
with
45 additions
and
5 deletions
dist/tools/git/README.md
+
5
−
1
View file @
e6554181
...
@@ -16,6 +16,10 @@ In order to set up the cache, do:
...
@@ -16,6 +16,10 @@ In order to set up the cache, do:
The used path can be overridden using the "GIT_CACHE_DIR" environment
The used path can be overridden using the "GIT_CACHE_DIR" environment
variable.
variable.
The cache repository will be used to cache multiple remote repositories.
The cache repository will be used to cache multiple remote repositories.
-
add a repository to the cache: "git cache add
\<
name
\>
\<
URL
\>
-
add a repository to the cache: "git cache add
\<
URL
\>
[
\<
name
\>
]
-
whenever needed (at least once after adding a repository),
-
whenever needed (at least once after adding a repository),
run "git cache update"
run "git cache update"
If the GIT_CACHE_AUTOADD environment variable is set to "1", a "git cache
clone" will add the repository to the cache (and immediately update) if the url
is not yet in the cache.
This diff is collapsed.
Click to expand it.
dist/tools/git/git-cache
+
40
−
4
View file @
e6554181
...
@@ -6,7 +6,8 @@ git_cache() {
...
@@ -6,7 +6,8 @@ git_cache() {
init
()
{
init
()
{
set
-ex
set
-ex
test
-d
"
${
GIT_CACHE_DIR
}
/.git"
||
{
local
_git_dir
=
"
$(
git_cache rev-parse
--git-dir
2>/dev/null
)
"
test
"
$_git_dir
"
==
"."
-o
"
$_git_dir
"
==
".git"
||
{
mkdir
-p
"
${
GIT_CACHE_DIR
}
"
mkdir
-p
"
${
GIT_CACHE_DIR
}
"
git_cache init
--bare
git_cache init
--bare
...
@@ -17,7 +18,19 @@ init() {
...
@@ -17,7 +18,19 @@ init() {
add
()
{
add
()
{
set
-ex
set
-ex
git_cache remote add
$1
$2
if
[
$#
-eq
1
]
;
then
local
repo
=
"
$1
"
local
name
=
"
$(
_remote_name
$repo
)
"
else
local
repo
=
"
$1
"
local
name
=
"
$2
"
fi
if
!
is_cached
"
$repo
"
;
then
git_cache remote add
"
$name
"
"
$repo
"
else
echo
"git-cache:
$url
already in cache"
fi
set
+ex
set
+ex
}
}
...
@@ -28,6 +41,17 @@ update() {
...
@@ -28,6 +41,17 @@ update() {
set
+ex
set
+ex
}
}
is_cached
()
{
set
+ex
local
url
=
"
$1
"
local
REMOTES
=
"
$(
git_cache remote show
)
"
for
remote
in
$REMOTES
;
do
test
"
$(
git_cache remote get-url
$remote
)
"
==
"
$url
"
&&
return
0
done
set
-ex
return
1
}
list
()
{
list
()
{
local
REMOTES
=
"
$(
git_cache remote show
)
"
local
REMOTES
=
"
$(
git_cache remote show
)
"
for
remote
in
$REMOTES
;
do
for
remote
in
$REMOTES
;
do
...
@@ -50,13 +74,24 @@ _check_commit() {
...
@@ -50,13 +74,24 @@ _check_commit() {
git_cache cat-file
-e
${
1
}
^
{
commit
}
git_cache cat-file
-e
${
1
}
^
{
commit
}
}
}
_remote_name
()
{
basename
"
$*
"
.git
}
clone
()
{
clone
()
{
set
-ex
set
-ex
local
REMOTE
=
"
${
1
}
"
local
REMOTE
=
"
${
1
}
"
local
SHA1
=
"
${
2
}
"
local
SHA1
=
"
${
2
}
"
local
REMOTE_NAME
=
"
$(
base
name
$REMOTE
)
"
local
REMOTE_NAME
=
"
$(
_remote_
name
$REMOTE
)
"
local
TARGET_PATH
=
"
${
3
:-${
REMOTE_NAME
}}
"
local
TARGET_PATH
=
"
${
3
:-${
REMOTE_NAME
}}
"
if
[
"
$GIT_CACHE_AUTOADD
"
==
"1"
]
;
then
if
!
is_cached
"
$REMOTE
"
;
then
add
"
$REMOTE
"
update
"
$(
_remote_name
$REMOTE
)
"
fi
fi
if
_check_commit
$2
2>&1
;
then
if
_check_commit
$2
2>&1
;
then
git init
"
${
TARGET_PATH
}
"
git init
"
${
TARGET_PATH
}
"
git_cache tag commit
$SHA1
$SHA1
||
true
# ignore possibly already existing tag
git_cache tag commit
$SHA1
$SHA1
||
true
# ignore possibly already existing tag
...
@@ -76,7 +111,8 @@ usage() {
...
@@ -76,7 +111,8 @@ usage() {
echo
"usage:"
echo
"usage:"
echo
""
echo
""
echo
" git cache init initialize git cache"
echo
" git cache init initialize git cache"
echo
" git cache add <name> <url> add repository <url> with name <name>"
echo
" git cache add <url> [<name>] add repository <url> with name <name>"
echo
" (if no name given, use
\"
basename
$url
.git
\"
"
echo
" git cache list list cached repositories"
echo
" git cache list list cached repositories"
echo
" git cache drop <name> drop repo from cache"
echo
" git cache drop <name> drop repo from cache"
echo
" git cache update [<name>] fetch repo named <name> (or all)"
echo
" git cache update [<name>] fetch repo named <name> (or all)"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment