Skip to content

Commit b82d7cc

Browse files
committed
Adjusted tag fetch to use a name and not hash
1 parent f6cc4ca commit b82d7cc

File tree

12 files changed

+312
-274
lines changed

12 files changed

+312
-274
lines changed

.idea/workspace.xml

+280-250
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/gc.go

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"github.com/hashload/boss/core/gc"
5+
"github.com/hashload/boss/msg"
56
"github.com/spf13/cobra"
67
)
78

@@ -10,6 +11,7 @@ var gcCmd = &cobra.Command{
1011
Short: "Garbage collector",
1112
Long: `Garbage collector to remove old cached files`,
1213
Run: func(cmd *cobra.Command, args []string) {
14+
msg.Info("Running GC...")
1315
gc.RunGC()
1416
},
1517
}

cmd/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var initCmd = &cobra.Command{
3333
pkgJson.Version = getParamOrDef("version: (1.0.0)", "1.0.0")
3434
pkgJson.Description = getParamOrDef("description", "")
3535
pkgJson.MainSrc = getParamOrDef("source folder: (src/)", "src/")
36-
pkgJson.Supported = getParamOrDef("supported version: (xe+)", "xe+")
36+
pkgJson.Supported = getParamOrDef("supported version: (26 'Delphi XE / C++Builder XE')", "26")
3737

3838
pkgJson.Private = false
3939

cmd/install.go

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ var installCmd = &cobra.Command{
3535
ver = split[1]
3636
}
3737
if dev {
38-
3938
loadPackage.AddDevDependency(split[0], ver)
4039
} else {
4140
loadPackage.AddDependency(split[0], ver)

cmd/upgrade.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func checkVersion(newVersion string) bool {
5959
if needUpdate {
6060
println(consts.VERSION, " -> ", newVersion)
6161
} else {
62-
println(consts.VERSION, " <= ", newVersion)
62+
println(newVersion)
6363
println("already up to date!")
6464
}
6565
return needUpdate
@@ -79,8 +79,13 @@ func getLink() (err error, link string, size float64, version string) {
7979
if err := json.Unmarshal(contents, &obj); err != nil {
8080
msg.Die("failed in parse version JSON")
8181
}
82-
bossExe := obj["assets"].([]interface{})[0].(map[string]interface{})
83-
return nil, bossExe["browser_download_url"].(string), bossExe["size"].(float64), obj["tag_name"].(string)
82+
for _, value := range obj["assets"].([]interface{}) {
83+
bossExe := value.(map[string]interface{})
84+
if bossExe["name"].(string) == "boss.exe" {
85+
return nil, bossExe["browser_download_url"].(string), bossExe["size"].(float64), obj["tag_name"].(string)
86+
}
87+
}
88+
return fmt.Errorf("not found"), "", 0, ""
8489
}
8590

8691
func closeFile(out *os.File) {

consts/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ const XML_TAG_NAME_PROPERTY_ATTRIBUTE_VALUE string = "'$(Base)'!=''"
1010

1111
const XML_TAG_NAME_LIBRARY_PATH string = "DCC_UnitSearchPath"
1212

13-
const VERSION string = "v1.5.4"
13+
const VERSION string = "v1.6.0"
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package compiler
2+
3+
type DelphiVer int
4+
5+
const (
6+
DelphiSeattle10 DelphiVer = 0
7+
DelphiBerlin101 DelphiVer = 1
8+
DelphiTokyo DelphiVer = 2
9+
DelphiRio DelphiVer = 3
10+
)

core/gc/gc.go

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
)
1212

1313
func RunGC() {
14-
msg.Info("Running GC...")
1514
_ = filepath.Walk(filepath.Join(env.GetCacheDir(), "info"), func(path string, info os.FileInfo, err error) error {
1615
if info.IsDir() {
1716
return nil

core/git/main.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ func UpdateCache(dep models.Dependency) *git.Repository {
4242
repository = refreshCopy(dep)
4343
} else {
4444
worktree, _ := repository.Worktree()
45-
worktree.Reset(&git.ResetOptions{
45+
_ = worktree.Reset(&git.ResetOptions{
4646
Mode: git.HardReset,
4747
})
4848
}
49-
repository.Fetch(&git.FetchOptions{
50-
Force: true,
51-
Auth: models.GlobalConfiguration.GetAuth(dep.GetURLPrefix())})
49+
_ = repository.Fetch(&git.FetchOptions{
50+
Force: true,
51+
Progress: os.Stdout,
52+
Auth: models.GlobalConfiguration.GetAuth(dep.GetURLPrefix())})
5253
initSubmodules(dep, repository)
5354
return repository
5455
}

core/main.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515

1616
var processed = make([]string, 0)
1717

18-
var processedOld = 0
19-
2018
func EnsureDependencies(pkg *models.Package) {
2119
if pkg.Dependencies == nil {
2220
return
@@ -56,11 +54,10 @@ func ensureModules(pkg *models.Package, deps []models.Dependency) {
5654
short := version.Name().Short()
5755
newVersion, err := semver.NewVersion(short)
5856
if err != nil {
59-
msg.Warn("\tErro to parse version %s: '%s' in dependency %s", short, err, dep.Repository)
57+
msg.Warn("\tInvalid semantic version: %s", short)
6058
continue
6159
}
6260
if constraints.Check(newVersion) {
63-
//msg.Info("Dependency %s with version %s", dep.Repository, newVersion.String())
6461
hasMatch = true
6562
if bestVersion == nil || newVersion.GreaterThan(bestVersion) {
6663
bestMatch = version
@@ -80,7 +77,8 @@ func ensureModules(pkg *models.Package, deps []models.Dependency) {
8077
worktree.Filesystem.TempFile(filepath.Join(env.GetCacheDir(), "tmp"), "tpt")
8178
err := worktree.Checkout(&git2.CheckoutOptions{
8279
Force: true,
83-
Hash: bestMatch.Hash(),
80+
//Hash: bestMatch.Hash(),
81+
Branch: bestMatch.Name(),
8482
})
8583
if err != nil {
8684
msg.Die("\tError on switch to needed version from dependency: %s\n%s", dep.Repository, err)

models/package.go

-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ func (p *Package) RemoveDependency(dep string) {
6262

6363
func getNew(file string) *Package {
6464
res := new(Package)
65-
/*
66-
ALL PROPS CREATION
67-
res.DevDependencies = make(map[string]interface{})
68-
res.Dependencies = make(map[string]interface{})
69-
res.Scripts = make(map[string]interface{})
70-
*/
7165
res.fileName = file
7266
res.IsNew = true
7367

utils/dprojUtil.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func Contains(a []string, x string) bool {
105105
return false
106106
}
107107

108-
func GetNewPaths(paths []string) []string {
108+
func getNewPaths(paths []string) []string {
109109
dir, _ := os.Getwd()
110110
path := filepath.Join(dir, consts.FOLDER_DEPENDENCIES)
111111
_, e := os.Stat(path)
@@ -135,7 +135,7 @@ func processCurrentPathpaths(node *etree.Element) {
135135
}
136136
}
137137

138-
currentPaths = GetNewPaths(currentPaths)
138+
currentPaths = getNewPaths(currentPaths)
139139

140140
node.SetText(strings.Join(currentPaths, ";"))
141141

0 commit comments

Comments
 (0)