Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and improve the upgrade menu #265

Merged
merged 4 commits into from
Mar 22, 2018
Merged

Conversation

Morganamilo
Copy link
Contributor

Fixes #218

The goroutine code is simpler now so hopefully I didn't make a dumb mistake but their still easy to mess up so I'd like a second opinion before merging.

See commits for a more detailed description.

@Morganamilo Morganamilo requested a review from Jguer March 21, 2018 01:07

fmt.Println(bold(cyan("::") + " Searching databases for updates..."))
wg.Add(1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small detail, here maybe wg.Add(2) and immediately launch the 2 go routines and then print Searching databases for updates and Searching AUR for updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So like?

wg.Add(2)
	go func() {
		repoUp, repoErr = upRepo(local)
		wg.Done()
	}()

	go func() {
		aurUp, aurErr = upAUR(remote, remoteNames, dt)
		wg.Done()
	}()


	fmt.Println(bold(cyan("::") + " Searching databases for updates..."))
	fmt.Println(bold(cyan("::") + " Searching AUR for updates..."))

	if config.Devel {
		wg.Add(1)
		go func() {
			develUp, develErr = upDevel(remote)
			wg.Done()
		}()

		fmt.Println(bold(cyan("::") + " Checking development packages..."))
	}
	
	wg.Wait()

I much prefer how it is now, plus I always prefer telling the user you're about to do something before starting to do it. Either way there should be no performance difference in the code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just to leave the main go routine a bit more entertained, I don't object to leaving it as is

@Jguer
Copy link
Owner

Jguer commented Mar 21, 2018

Don't have many updates to test it on now, from a code perspective it seem good, I can try and update using this version for another day, but I don't see any issue with it

@Morganamilo
Copy link
Contributor Author

Added a new commit 95bbc0e that fixes #146. Using the method I described in #146.

@Jguer
Copy link
Owner

Jguer commented Mar 22, 2018

Worked fine, on a mix of repo,aur and devel packages

Before the goroutines in upList() were layed out like:
	upLists()
	|- - - 	upRepo()
	|- - - 	pAur()
		| - - -	upDevel()

Simplified by moving upDevel() from upAur() to upList():
	upList()
	|- - - 	upRepo()
	|- - - 	upAur()
	|- - - 	upDevel()

With the simpler layout it was easy to then remove some un need channel
useage entirely and use WaitGroups in other places.

Now if any of the three inner functions error, upList() will return
a combined error instead of just printing the error and carrying on.
Sort accending instead of decending
Sort by package name as well as repo name
Sort AUR packages as well as repo packages
Previosly during `yay -Su` Yay would pass
`pacman -S <packages that need upgrade>` to pacman.

Instead pass `pacman -Su --ignore <number menu choices>`

This allows yay to handle replaces and package downgrades `-Suu`
@Morganamilo Morganamilo merged commit dbe0ace into Jguer:master Mar 22, 2018
@Morganamilo
Copy link
Contributor Author

As mentioned in 98ea801 This should fix the replaces problem in #146. I couldn't really test it at the time because replaces don't come up that often.

image

It finally came up though so I can confirm it's working.

@Morganamilo Morganamilo deleted the refactor branch April 15, 2018 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants