Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
orchestra-v3
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Alessandro Di Federico
orchestra-v3
Commits
e2f0d22c
Commit
e2f0d22c
authored
4 years ago
by
Filippo Cremonese
Browse files
Options
Downloads
Patches
Plain Diff
Cache git ls-remote output
parent
d0ff9ce0
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
orchestra/actions/clone.py
+23
-1
23 additions, 1 deletion
orchestra/actions/clone.py
orchestra/cmds/update.py
+5
-0
5 additions, 0 deletions
orchestra/cmds/update.py
with
28 additions
and
1 deletion
orchestra/actions/clone.py
+
23
−
1
View file @
e2f0d22c
import
json
import
os.path
import
re
from
functools
import
lru_cache
...
...
@@ -53,9 +54,30 @@ class CloneAction(Action):
@lru_cache
()
def
_ls_remote
(
self
,
remote
):
return
run_script
(
cache_filepath
=
os
.
path
.
join
(
self
.
config
.
orchestra_dotdir
,
"
remote_refs_cache.json
"
)
if
os
.
path
.
exists
(
cache_filepath
):
with
open
(
cache_filepath
,
"
rb
"
)
as
f
:
cached_data
=
json
.
loads
(
f
.
read
())
if
self
.
build
.
qualified_name
in
cached_data
:
return
cached_data
[
self
.
build
.
qualified_name
]
data
=
run_script
(
f
'
git ls-remote -h --refs
"
{
remote
}
"'
,
quiet
=
True
,
environment
=
self
.
environment
,
check_returncode
=
False
).
stdout
.
decode
(
"
utf-8
"
)
if
os
.
path
.
exists
(
cache_filepath
):
with
open
(
cache_filepath
,
"
rb
"
)
as
f
:
cached_data
=
json
.
loads
(
f
.
read
())
else
:
cached_data
=
{}
cached_data
[
self
.
build
.
qualified_name
]
=
data
# TODO: prevent race condition, if two clone actions run at the same time
with
open
(
cache_filepath
,
"
w
"
)
as
f
:
json
.
dump
(
cached_data
,
f
)
return
data
This diff is collapsed.
Click to expand it.
orchestra/cmds/update.py
+
5
−
0
View file @
e2f0d22c
...
...
@@ -21,6 +21,11 @@ def handle_update(args, config: Configuration):
else
:
clone_binary_archive
(
name
,
url
,
config
)
logger
.
info
(
"
Resetting ls-remote cached info
"
)
ls_remote_cache
=
os
.
path
.
join
(
config
.
orchestra_dotdir
,
"
remote_refs_cache.json
"
)
if
os
.
path
.
exists
(
ls_remote_cache
):
os
.
remove
(
ls_remote_cache
)
logger
.
info
(
"
Updating repositories
"
)
for
git_repo
in
glob
(
os
.
path
.
join
(
config
.
sources_dir
,
"
**/.git
"
),
recursive
=
True
):
git_repo
=
os
.
path
.
dirname
(
git_repo
)
...
...
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