Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
semantic-release
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
go-semantic-release
semantic-release
Commits
42837380
Commit
42837380
authored
Feb 1, 2023
by
Christoph Witzko
Browse files
Options
Downloads
Patches
Plain Diff
feat: extract batched plugin archive
parent
8f1db0a0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/plugin/discovery/discovery.go
+2
-3
2 additions, 3 deletions
pkg/plugin/discovery/discovery.go
pkg/plugin/discovery/download.go
+75
-0
75 additions, 0 deletions
pkg/plugin/discovery/download.go
pkg/plugin/discovery/local.go
+1
-1
1 addition, 1 deletion
pkg/plugin/discovery/local.go
with
78 additions
and
4 deletions
pkg/plugin/discovery/discovery.go
+
2
−
3
View file @
42837380
...
...
@@ -127,7 +127,6 @@ func (d *Discovery) FindPluginsWithBatchResolver(resolverName string, pInfos []*
if
err
!=
nil
{
return
err
}
// TODO
_
=
batchDownloadInfo
return
nil
return
downloadBatchPlugins
(
missingPlugins
,
batchDownloadInfo
,
d
.
config
.
ShowProgress
)
}
This diff is collapsed.
Click to expand it.
pkg/plugin/discovery/download.go
+
75
−
0
View file @
42837380
...
...
@@ -127,3 +127,78 @@ func downloadPlugin(pluginInfo *plugin.Info, downloadInfo *resolver.PluginDownlo
}
return
targetFile
,
nil
}
//gocyclo:ignore
func
downloadBatchPlugins
(
pluginInfos
[]
*
plugin
.
Info
,
downloadInfo
*
resolver
.
BatchPluginDownloadInfo
,
showProgress
bool
)
error
{
req
,
err
:=
grab
.
NewRequest
(
PluginDir
,
downloadInfo
.
URL
)
if
err
!=
nil
{
return
err
}
if
downloadInfo
.
Checksum
!=
""
{
sum
,
decErr
:=
hex
.
DecodeString
(
downloadInfo
.
Checksum
)
if
decErr
!=
nil
{
return
fmt
.
Errorf
(
"could not decode checksum: %w"
,
decErr
)
}
req
.
SetChecksum
(
sha256
.
New
(),
sum
,
true
)
}
res
:=
grab
.
DefaultClient
.
Do
(
req
)
if
showProgress
{
showDownloadProgressBar
(
"batched-plugins"
,
res
)
}
err
=
res
.
Err
()
if
err
!=
nil
{
return
err
}
defer
os
.
Remove
(
res
.
Filename
)
tgzFile
,
err
:=
os
.
Open
(
res
.
Filename
)
if
err
!=
nil
{
return
err
}
defer
tgzFile
.
Close
()
gunzip
,
err
:=
gzip
.
NewReader
(
tgzFile
)
if
err
!=
nil
{
return
err
}
defer
gunzip
.
Close
()
tarReader
:=
tar
.
NewReader
(
gunzip
)
for
{
header
,
tarErr
:=
tarReader
.
Next
()
if
errors
.
Is
(
tarErr
,
io
.
EOF
)
{
break
}
if
tarErr
!=
nil
{
return
tarErr
}
if
header
.
Typeflag
!=
tar
.
TypeReg
{
continue
}
outFileName
:=
path
.
Join
(
PluginDir
,
header
.
Name
)
outDirName
:=
path
.
Dir
(
outFileName
)
if
err
=
os
.
MkdirAll
(
outDirName
,
0
o755
);
err
!=
nil
{
return
err
}
outFile
,
oErr
:=
os
.
OpenFile
(
outFileName
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0
o755
)
if
oErr
!=
nil
{
return
oErr
}
_
,
cErr
:=
io
.
Copy
(
outFile
,
tarReader
)
_
=
outFile
.
Close
()
if
cErr
!=
nil
{
return
cErr
}
for
_
,
pluginInfo
:=
range
pluginInfos
{
if
strings
.
HasPrefix
(
path
.
Join
(
PluginDir
,
header
.
Name
),
pluginInfo
.
PluginPath
)
{
pluginInfo
.
BinPath
=
outFileName
}
}
}
return
nil
}
This diff is collapsed.
Click to expand it.
pkg/plugin/discovery/local.go
+
1
−
1
View file @
42837380
...
...
@@ -17,7 +17,7 @@ const PluginDir = ".semrel"
var
osArchDir
=
runtime
.
GOOS
+
"_"
+
runtime
.
GOARCH
func
setAndEnsurePluginPath
(
pluginInfo
*
plugin
.
Info
)
error
{
pluginPath
:=
path
.
Join
(
PluginDir
,
osArchDir
,
pluginInfo
.
NormalizedName
)
pluginPath
:=
path
.
Join
(
PluginDir
,
osArchDir
,
pluginInfo
.
Short
NormalizedName
)
if
_
,
err
:=
os
.
Stat
(
pluginPath
);
os
.
IsNotExist
(
err
)
{
err
=
os
.
MkdirAll
(
pluginPath
,
0
o755
)
if
err
!=
nil
{
...
...
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