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
5247c3a1
There was an error fetching the commit references. Please try again later.
Commit
5247c3a1
authored
4 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
bug fix
parent
ff1e65ed
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
+55
-49
55 additions, 49 deletions
tools/nuget-download-package/main.go
with
55 additions
and
49 deletions
tools/nuget-download-package/main.go
+
55
−
49
View file @
5247c3a1
...
@@ -179,67 +179,73 @@ func decidePackageVersionRange(packageName, frameworkVersion string, indexJsons
...
@@ -179,67 +179,73 @@ func decidePackageVersionRange(packageName, frameworkVersion string, indexJsons
func
decidePackageVersion
(
frameworkVersion
,
packageVersion
string
,
indexJsons
,
indexJsons_Login
[]
string
)
(
maxAvailableVersion
,
maxAvailableVersionUrl
,
maxAvailableVersionUrlLogin
string
)
{
func
decidePackageVersion
(
frameworkVersion
,
packageVersion
string
,
indexJsons
,
indexJsons_Login
[]
string
)
(
maxAvailableVersion
,
maxAvailableVersionUrl
,
maxAvailableVersionUrlLogin
string
)
{
// The golang json parse library sucks. Prevent it from crashing
// The golang json parse library sucks. Prevent it from crashing
// on a json syntax error.
// on a json syntax error.
//
// This function is very ugly. Fucking go-json library and go exception.
defer
func
()
{
recover
()}
()
defer
func
()
{
recover
()}
()
for
indexJson_currIndex
,
indexJson
:=
range
indexJsons
{
for
indexJson_currIndex
,
indexJson
:=
range
indexJsons
{
defer
func
()
{
recover
()}
()
// try parse, skip this entry on error
func
()
{
// entry = xml.findall("/items/[]/items/[]/catalogEntry")
defer
func
()
{
recover
()
}()
// try parse, skip this entry on error
// entry/version, entry/dependencyGroups[]/targetFramework, entry/../packageContent
// entry = xml.findall("/items/[]/items/[]/catalogEntry")
// If there's no `targetFramework` in dependencyGroups, this package depends on specific version of parent package. it sucks.
// entry/version, entry/dependencyGroups[]/targetFramework, entry/../packageContent
var
j1
map
[
string
]
interface
{}
// If there's no `targetFramework` in dependencyGroups, this package depends on specific version of parent package. it sucks.
json
.
Unmarshal
([]
byte
(
indexJson
),
&
j1
)
var
j1
map
[
string
]
interface
{}
j2
:=
j1
[
"items"
]
.
([]
interface
{})
json
.
Unmarshal
([]
byte
(
indexJson
),
&
j1
)
for
_
,
j2ele
:=
range
j2
{
j2
:=
j1
[
"items"
]
.
([]
interface
{})
defer
func
()
{
recover
()}
()
// try parse, skip this entry on error
for
_
,
j2ele
:=
range
j2
{
j3
:=
j2ele
.
(
map
[
string
]
interface
{})[
"items"
]
j3
:=
j2ele
.
(
map
[
string
]
interface
{})[
"items"
]
j4
:=
j3
.
([]
interface
{})
j4
:=
j3
.
([]
interface
{})
for
_
,
jPkgVersionItem_
:=
range
j4
{
for
_
,
jPkgVersionItem_
:=
range
j4
{
defer
func
()
{
recover
()}
()
// try parse, skip this entry on error
func
()
{
jPkgVersionItem
:=
jPkgVersionItem_
.
(
map
[
string
]
interface
{})
defer
func
()
{
recover
()
}()
// try parse, skip this entry on error
jCatalogEntry
:=
jPkgVersionItem
[
"catalogEntry"
]
.
(
map
[
string
]
interface
{})
jPkgVersionItem
:=
jPkgVersionItem_
.
(
map
[
string
]
interface
{})
myVersionText
:=
jCatalogEntry
[
"version"
]
.
(
string
)
jCatalogEntry
:=
jPkgVersionItem
[
"catalogEntry"
]
.
(
map
[
string
]
interface
{})
// log.Println("DEBUG: reaching " + myVersionText)
myVersionText
:=
jCatalogEntry
[
"version"
]
.
(
string
)
// log.Println("DEBUG: reaching " + myVersionText)
// Let's check if this version is ok
thisPkgVersionIsOk
:=
false
// Let's check if this version is ok
thisPkgVersionIsOk
:=
false
if
frameworkVersion
!=
""
{
if
j5
,
ok
:=
jCatalogEntry
[
"dependencyGroups"
];
ok
{
if
frameworkVersion
!=
""
{
for
_
,
j6
:=
range
j5
.
([]
interface
{})
{
if
j5
,
ok
:=
jCatalogEntry
[
"dependencyGroups"
];
ok
{
j7
:=
j6
.
(
map
[
string
]
interface
{})
for
_
,
j6
:=
range
j5
.
([]
interface
{})
{
if
j8
,
ok
:=
j7
[
"targetFramework"
];
ok
{
j7
:=
j6
.
(
map
[
string
]
interface
{})
if
frameworkVersion
==
netVersionNugetFormatToStandardFormat
(
j8
.
(
string
))
{
if
j8
,
ok
:=
j7
[
"targetFramework"
];
ok
{
thisPkgVersionIsOk
=
true
if
frameworkVersion
==
netVersionNugetFormatToStandardFormat
(
j8
.
(
string
))
{
break
thisPkgVersionIsOk
=
true
break
}
}
else
{
// this pkgVersion has no targetFramework limitation.
thisPkgVersionIsOk
=
true
}
}
}
}
else
{
}
else
{
//
this pkgVersion has no targetFramework limitation.
//
no dependencyGroups at all
thisPkgVersionIsOk
=
true
thisPkgVersionIsOk
=
true
}
}
}
}
}
else
{
// no dependencyGroups at all
thisPkgVersionIsOk
=
true
}
}
if
packageVersion
!=
""
{
if
packageVersion
!=
""
{
thisPkgVersionIsOk
=
packageVersion
==
myVersionText
thisPkgVersionIsOk
=
packageVersion
==
myVersionText
}
}
if
thisPkgVersionIsOk
{
if
thisPkgVersionIsOk
{
// log.Println("DEBUG: good " + myVersionText)
// log.Println("DEBUG: good " + myVersionText)
// This version is ok! Log it.
// This version is ok! Log it.
myVersionUrl
:=
jPkgVersionItem
[
"packageContent"
]
.
(
string
)
myVersionUrl
:=
jPkgVersionItem
[
"packageContent"
]
.
(
string
)
if
version
.
CompareSimple
(
myVersionText
,
maxAvailableVersion
)
==
1
{
if
version
.
CompareSimple
(
myVersionText
,
maxAvailableVersion
)
==
1
{
// if left > right
// if left > right
maxAvailableVersion
=
myVersionText
maxAvailableVersion
=
myVersionText
maxAvailableVersionUrl
=
myVersionUrl
maxAvailableVersionUrl
=
myVersionUrl
maxAvailableVersionUrlLogin
=
indexJsons_Login
[
indexJson_currIndex
]
maxAvailableVersionUrlLogin
=
indexJsons_Login
[
indexJson_currIndex
]
}
}
}
// log.Println("DEBUG: leaving " + myVersionText)
}()
// catch exception and continue
}
}
}
}
}
}
()
// catch exception and continue
}
}
return
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