nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

use CARGO_HOME for git repos #66

Closed matthiaskrgr closed 5 years ago

matthiaskrgr commented 6 years ago

Just an idea: instead of cloning the repos into /tmp, it would be awesome if we could instead check if we already have the git repo in ~/CARGO_HOME/git/db/ and if so, update it using cargo and then check "git log " inside the bare repo to determine if the repo needs to be updated.

nabijaczleweli commented 6 years ago

$CARGO_HOME/git/db/ contains repos at specific hashes, so checking or updating them seems like a terrible idea? Also, how does one "update it using cargo"? v confused tbh

matthiaskrgr commented 6 years ago

In .cargo/git we have a "db" dir which contains bare repos and a "checkouts" dir which contains the checked out repos.

When we do cargo install --git of a package, cargo will fetch updates of that repos and then look if we do a new updated checkout I think.

The idea is, instead of cloning into /tmp, check if we have any git-repo-crates installed (as before), if yes, call the function that cargo uses to update (I assume it runs something like "git fetch") the bare repo (for example ~/.cargo/git/db/cargo-update-6ba56231f2c43182). After updating, we check if the git-hash of the installed package matches the tip of the respective branch of the bare repo to find out if the installed package is out of date.

nabijaczleweli commented 5 years ago

Would you be so kind so as to test with the commit above?

matthiaskrgr commented 5 years ago

Looks good to me! Thanks a lot!

nabijaczleweli commented 5 years ago

Released in v1.8.0, and thanks once more!