Merge pull request #183 from Morganamilo/fix#88

Save the VSC info when install finishes.
This commit is contained in:
Morgana 2018-02-27 19:08:01 +00:00 committed by GitHub
commit 9c4b4d73f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 25 deletions

11
cmd.go
View file

@ -127,8 +127,6 @@ func initYay() (err error) {
/////////////////
// vcs config //
////////////////
updated = false
vfile, err := os.OpenFile(vcsFile, os.O_RDONLY|os.O_CREATE, 0644)
if err == nil {
defer vfile.Close()
@ -237,15 +235,6 @@ cleanup:
//if we fail to save the configuration
//at least continue on and try clean up other parts
if updated {
err = saveVCSInfo()
if err != nil {
fmt.Println(err)
status = 1
}
}
if changedConfig {
err = config.saveConfig()

View file

@ -57,9 +57,6 @@ var vcsFile string
//completion file
var completionFile string
// Updated returns if database has been updated
var updated bool
// changedConfig holds whether or not the config has changed
var changedConfig bool

View file

@ -314,16 +314,18 @@ func askEditPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) error {
return nil
}
func updateVSCdb(pkgbuild *gopkg.PKGBUILD) {
func updateVSCdb(pkgs []*rpc.Pkg, pkgbuild *gopkg.PKGBUILD) {
for _, pkgsource := range pkgbuild.Source {
owner, repo := parseSource(pkgsource)
if owner != "" && repo != "" {
err := branchInfo(pkgbuild.Pkgbase, owner, repo)
for _, pkg := range pkgs {
err := branchInfo(pkg.Name, owner, repo)
if err != nil {
fmt.Println(err)
}
}
}
}
}
func parsesrcinfosFile(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, bases map[string][]*rpc.Pkg) error {
@ -339,7 +341,7 @@ func parsesrcinfosFile(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, bas
}
srcinfos[pkg.PackageBase] = pkgbuild
updateVSCdb(pkgbuild)
updateVSCdb(bases[pkg.PackageBase], pkgbuild)
}
return nil
@ -367,7 +369,6 @@ func parsesrcinfosGenerate(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
}
srcinfos[pkg.PackageBase] = pkgbuild
updateVSCdb(pkgbuild)
}
return nil
@ -402,10 +403,7 @@ func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) (err
}
func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, targets stringSet, parser *arguments, bases map[string][]*rpc.Pkg) error {
//for n := len(pkgs) -1 ; n > 0; n-- {
for n := 0; n < len(pkgs); n++ {
pkg := pkgs[n]
for _, pkg := range pkgs {
dir := config.BuildDir + pkg.PackageBase + "/"
built := true
@ -469,6 +467,8 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
if err != nil {
return err
}
updateVSCdb(bases[pkg.PackageBase], srcinfo)
if len(depArguments.targets) > 0 {
err = passToPacman(depArguments)
if err != nil {

8
vcs.go
View file

@ -129,7 +129,7 @@ func inStore(pkgName string) *Info {
// branchInfo updates saved information
func branchInfo(pkgName string, owner string, repoName string) (err error) {
updated = true
updated := false
var newRepo repo
var newBranches branches
url := "https://api.github.com/repos/" + owner + "/" + repoName
@ -155,6 +155,8 @@ func branchInfo(pkgName string, owner string, repoName string) (err error) {
for _, e := range newBranches {
if e.Name == defaultBranch {
updated = true
if packinfo != nil {
packinfo.Package = pkgName
packinfo.URL = url
@ -165,6 +167,10 @@ func branchInfo(pkgName string, owner string, repoName string) (err error) {
}
}
if updated {
saveVCSInfo()
}
return
}