Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openxt
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
msc
openxt
Commits
ff7a1b89
There was an error fetching the commit references. Please try again later.
Commit
ff7a1b89
authored
4 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
bug fix
parent
5247c3a1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/nuget-download-package/main.go
+24
-5
24 additions, 5 deletions
tools/nuget-download-package/main.go
with
24 additions
and
5 deletions
tools/nuget-download-package/main.go
+
24
−
5
View file @
ff7a1b89
...
...
@@ -51,7 +51,7 @@ func netVersionNugetFormatToStandardFormat(netVersionNugetFormat string) string
}
else
if
strings
.
HasPrefix
(
netVersionNugetFormat
,
".netstandard"
)
{
return
netVersionNugetFormat
[
1
:
]
}
else
{
panic
(
"Unknown nuget-format net version: "
+
netVersionNugetFormat
)
return
"netunknown"
// do not panic please
}
}
...
...
@@ -183,6 +183,8 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
// This function is very ugly. Fucking go-json library and go exception.
defer
func
()
{
recover
()}
()
possibleAvailableVersion
,
possibleAvailableVersionUrl
,
PossibleAvailableVersionUrlLogin
:=
""
,
""
,
""
for
indexJson_currIndex
,
indexJson
:=
range
indexJsons
{
func
()
{
defer
func
()
{
recover
()
}()
// try parse, skip this entry on error
...
...
@@ -201,28 +203,30 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
jPkgVersionItem
:=
jPkgVersionItem_
.
(
map
[
string
]
interface
{})
jCatalogEntry
:=
jPkgVersionItem
[
"catalogEntry"
]
.
(
map
[
string
]
interface
{})
myVersionText
:=
jCatalogEntry
[
"version"
]
.
(
string
)
myVersionUrl
:=
jPkgVersionItem
[
"packageContent"
]
.
(
string
)
// log.Println("DEBUG: reaching " + myVersionText)
// Let's check if this version is ok
thisPkgVersionIsOk
:=
false
thisPkgVersionIsOk
,
thisPkgVersionIsPossibleOk
:=
false
,
false
if
frameworkVersion
!=
""
{
if
j5
,
ok
:=
jCatalogEntry
[
"dependencyGroups"
];
ok
{
for
_
,
j6
:=
range
j5
.
([]
interface
{})
{
j7
:=
j6
.
(
map
[
string
]
interface
{})
if
j8
,
ok
:=
j7
[
"targetFramework"
];
ok
{
// log.Println("DEBUG: " + frameworkVersion +" vs "+ netVersionNugetFormatToStandardFormat(j8.(string)))
if
frameworkVersion
==
netVersionNugetFormatToStandardFormat
(
j8
.
(
string
))
{
thisPkgVersionIsOk
=
true
break
}
}
else
{
// this pkgVersion has no targetFramework limitation.
thisPkgVersionIsOk
=
true
thisPkgVersionIs
Possible
Ok
=
true
}
}
}
else
{
// no dependencyGroups at all
thisPkgVersionIsOk
=
true
thisPkgVersionIs
Possible
Ok
=
true
}
}
...
...
@@ -233,7 +237,6 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
if
thisPkgVersionIsOk
{
// log.Println("DEBUG: good " + myVersionText)
// This version is ok! Log it.
myVersionUrl
:=
jPkgVersionItem
[
"packageContent"
]
.
(
string
)
if
version
.
CompareSimple
(
myVersionText
,
maxAvailableVersion
)
==
1
{
// if left > right
maxAvailableVersion
=
myVersionText
...
...
@@ -241,6 +244,15 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
maxAvailableVersionUrlLogin
=
indexJsons_Login
[
indexJson_currIndex
]
}
}
if
thisPkgVersionIsPossibleOk
{
// log.Println("DEBUG: possible good " + myVersionText)
if
version
.
CompareSimple
(
myVersionText
,
possibleAvailableVersion
)
==
1
{
// if left > right
possibleAvailableVersion
=
myVersionText
possibleAvailableVersionUrl
=
myVersionUrl
PossibleAvailableVersionUrlLogin
=
indexJsons_Login
[
indexJson_currIndex
]
}
}
// log.Println("DEBUG: leaving " + myVersionText)
}()
// catch exception and continue
}
...
...
@@ -248,6 +260,13 @@ func decidePackageVersion(frameworkVersion, packageVersion string, indexJsons, i
}()
// catch exception and continue
}
if
maxAvailableVersion
==
""
{
// That's so bad... No confirmed working version, let's use a possible working one.
maxAvailableVersion
=
possibleAvailableVersion
maxAvailableVersionUrl
=
possibleAvailableVersionUrl
maxAvailableVersionUrlLogin
=
PossibleAvailableVersionUrlLogin
}
return
}
...
...
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