Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #18 from WaffleLapkin/calm_down_dont_panicb
Browse files Browse the repository at this point in the history
Remove `.expect` from git code to prevent panics
  • Loading branch information
WaffleLapkin committed Sep 8, 2021
2 parents 427c509 + 78b19a6 commit 0d4d266
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## 0.1.9

### Fixed

- Panics on failed git pull (remove `.expect`s)

## 0.1.8

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "crate_upd_bot"
version = "0.1.8"
version = "0.1.9"
authors = ["Waffle <waffle.lapkin@gmail.com>"]
edition = "2018"

Expand Down
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ async fn main() {
std::thread::spawn(move || {
'outer: loop {
log::info!("start pulling updates");
pull(&repo, tx.clone()).expect("pull failed");

if let Err(err) = pull(&repo, tx.clone()) {
log::error!("couldn't pull new crate version from the index: {}", err)
}

log::info!("pulling updates finished");

// delay for `config.pull_delay` (default 5 min)
Expand Down Expand Up @@ -159,10 +163,7 @@ fn pull(
ch: Sender<(Crate, ActionKind, oneshot::Sender<Infallible>)>,
) -> Result<(), git2::Error> {
// fetch changes from remote index
repo.find_remote("origin")
.expect("couldn't find 'origin' remote")
.fetch(&["master"], None, None)
.expect("couldn't fetch new version of the index");
repo.find_remote("origin")?.fetch(&["master"], None, None)?;

// Collect all commits in the range `HEAD~1..FETCH_HEAD` (i.e. one before
// currently checked out to the last fetched)
Expand Down

0 comments on commit 0d4d266

Please sign in to comment.