Show tar diffs as diffs instead of editing

When looking at diffs of packages downloaded as tar achives actually
show a diff instead of opening the files in the ediror. This diff
is against /var/empty so it is not that useful. In realiy this is an
excuse to move the srcinfo parsing back down to after the git merge.

Viewing the build files in the editor requires the .srcinfos to be
parsed to know what .install files are used. Now viewing diffs does not
need the srcinfos so they can be moved to after we git merge.

Before now the srcinfo would have been of the previous version. This is
not much of a problem because we don't really use the srcinfo for much.
Checking the arch and pgpkeys which never really change.

Recently libc++ changed their pgp keys and yay missed that because it
parsed the old srcinfo without the new keys.

Viewing a proper diff for tars can be tossed on the todo by doing
something along the lines of:
	mv pkg{,.old}
	diff pkg{,.old}
	rm -rf pkg.old

But I doubt there are many people out there using tar so it's not much
of an issue.
This commit is contained in:
morganamilo 2018-07-19 22:19:24 +01:00
parent 298afac0e0
commit d1146de6d5
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E

View file

@ -189,12 +189,6 @@ func install(parser *arguments) error {
return err
}
//initial srcinfo parse before pkgver() bump
err = parseSRCINFOFiles(do.Aur, srcinfosStale, do.Bases)
if err != nil {
return err
}
var toDiff []*rpc.Pkg
var toEdit []*rpc.Pkg
@ -206,7 +200,7 @@ func install(parser *arguments) error {
}
if len(toDiff) > 0 {
err = showPkgBuildDiffs(toDiff, srcinfosStale, do.Bases, cloned)
err = showPkgBuildDiffs(toDiff, do.Bases, cloned)
if err != nil {
return err
}
@ -228,6 +222,12 @@ func install(parser *arguments) error {
return err
}
//initial srcinfo parse before pkgver() bump
err = parseSRCINFOFiles(do.Aur, srcinfosStale, do.Bases)
if err != nil {
return err
}
if config.EditMenu {
pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache)
toEdit, err = editNumberMenu(do.Aur, do.Bases, remoteNamesCache)
@ -650,7 +650,7 @@ func cleanBuilds(pkgs []*rpc.Pkg) {
}
}
func showPkgBuildDiffs(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, bases map[string][]*rpc.Pkg, cloned stringSet) error {
func showPkgBuildDiffs(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, cloned stringSet) error {
for _, pkg := range pkgs {
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
if shouldUseGit(dir) {
@ -681,20 +681,15 @@ func showPkgBuildDiffs(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, base
return err
}
} else {
editor, editorArgs := editor()
editorArgs = append(editorArgs, filepath.Join(dir, "PKGBUILD"))
for _, splitPkg := range srcinfos[pkg.PackageBase].SplitPackages() {
if splitPkg.Install != "" {
editorArgs = append(editorArgs, filepath.Join(dir, splitPkg.Install))
}
}
editcmd := exec.Command(editor, editorArgs...)
editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
err := editcmd.Run()
if err != nil {
return fmt.Errorf("Editor did not exit successfully, Aborting: %s", err)
args := []string{"diff"}
if useColor {
args = append(args, "--color=always")
} else {
args = append(args, "--color=never")
}
args = append(args, "--no-index", "/var/empty", dir)
// git always returns 1. why? I have no idea
show(passToGit(dir, args...))
}
}