Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
boilr
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
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
nimrod
boilr
Commits
6caa7833
Commit
6caa7833
authored
8 years ago
by
David McKay
Committed by
Tamer Tas
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allowing a version/branch string to be parsed in download url (#18)
Allows a version/branch string to be parsed in download url
parent
f1747fbb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/host/github.go
+18
-2
18 additions, 2 deletions
pkg/host/github.go
with
18 additions
and
2 deletions
pkg/host/github.go
+
18
−
2
View file @
6caa7833
...
...
@@ -2,16 +2,32 @@ package host
import
(
"path/filepath"
"regexp"
"strings"
)
// ZipURL returns the URL of the zip archive given a github repository URL.
func
ZipURL
(
url
string
)
string
{
var
version
=
"master"
url
=
strings
.
TrimSuffix
(
strings
.
TrimPrefix
(
url
,
"/"
),
"/"
)
if
strings
.
HasSuffix
(
url
,
"zip/master"
)
{
zipRegex
,
_
:=
regexp
.
Compile
(
`zip/(\S+)$`
)
if
zipRegex
.
MatchString
(
url
)
{
return
url
}
return
"https://codeload.github.com/"
+
filepath
.
Join
(
url
,
"/zip/master"
)
// So this could identify a port number, but since we only support github
// I don't believe using it as a version modifier is a problem. Though
// perhaps we should use something else instead?
if
strings
.
Contains
(
url
,
":"
)
{
parts
:=
strings
.
SplitAfter
(
url
,
":"
)
url
=
parts
[
0
]
version
=
parts
[
1
]
url
=
strings
.
TrimSuffix
(
url
,
":"
)
}
return
"https://codeload.github.com/"
+
filepath
.
Join
(
url
,
"/zip/"
+
version
)
}
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