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

Apply and enforce formatting #155

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
push:
branches: [master]
pull_request:

name: Continuous integration

jobs:

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
2 changes: 1 addition & 1 deletion gtk/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum UiError {
}

impl UiError {
pub fn iter_sources(&self) -> ErrorIter<'_> { ErrorIter { current: self.source() } }
pub fn iter_sources(&self) -> ErrorIter { ErrorIter { current: self.source() } }
}

#[derive(Debug, Error)]
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/events/background/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn run(
) {
let send: &dyn Fn(UiEvent) = &send;
if let Ok(ref mut client) = Client::new() {
info!("Checking for updates to daemon");
log::info!("Checking for updates to daemon");
if client.update_and_restart().unwrap_or(false) {
send(UiEvent::Updating);
let file = std::path::Path::new(pop_upgrade::RESTART_SCHEDULED);
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/events/background/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use pop_upgrade::{
};

pub fn download(client: &Client, send: &dyn Fn(UiEvent), info: ReleaseInfo) {
info!("downloading updates for {}", info.next);
log::info!("downloading updates for {}", info.next);
if !update(client, send) {
return;
}
Expand Down Expand Up @@ -110,7 +110,7 @@ pub fn download(client: &Client, send: &dyn Fn(UiEvent), info: ReleaseInfo) {
}

pub fn update(client: &Client, send: &dyn Fn(UiEvent)) -> bool {
info!("checking if updates are required");
log::info!("checking if updates are required");
let updates = match client.fetch_updates(Vec::new(), false) {
Ok(updates) => updates,
Err(why) => {
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/events/background/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn scan(client: &Client, send: &dyn Fn(UiEvent)) {
Ok(info) => {
is_lts = info.is_lts;
if devel || info.build >= 0 {
info!("upgrade from {} to {} is available", info.current, info.next);
log::info!("upgrade from {} to {} is available", info.current, info.next);

let upgrade_text = Cow::Owned(if reboot_ready {
format!("Pop!_OS is ready to upgrade to {}", info.next)
Expand All @@ -54,7 +54,7 @@ pub fn scan(client: &Client, send: &dyn Fn(UiEvent)) {
}
Err(why) => {
status_failed = true;
error!("failed to check for updates: {}", why);
log::error!("failed to check for updates: {}", why);
Cow::Borrowed("Failed to check for updates")
}
}
Expand Down
10 changes: 5 additions & 5 deletions gtk/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub fn attach(gui_receiver: glib::Receiver<UiEvent>, widgets: EventWidgets, mut
}

UiEvent::Completed(CompletedEvent::Recovery) => {
info!("successfully upgraded recovery partition");
log::info!("successfully upgraded recovery partition");
}

UiEvent::Completed(CompletedEvent::Refresh) => reboot(),
Expand Down Expand Up @@ -201,14 +201,14 @@ pub fn attach(gui_receiver: glib::Receiver<UiEvent>, widgets: EventWidgets, mut
UiEvent::ReleaseUpgradeDialog => release_upgrade_dialog(&mut state, &widgets),

UiEvent::Dismissed(dismissed) => {
info!("{} release", if dismissed { "dismissed" } else { "un-dismissed" });
log::info!("{} release", if dismissed { "dismissed" } else { "un-dismissed" });
if let Some(dismisser) = state.dismisser.as_mut() {
dismisser.set_dismissed(dismissed);
}
}

UiEvent::StatusChanged(from, to, why) => {
warn!("status changed from {} to {}: {}", from, to, why);
log::warn!("status changed from {} to {}: {}", from, to, why);
let _ = state.sender.send(BackgroundEvent::GetStatus(from));
}

Expand Down Expand Up @@ -267,7 +267,7 @@ fn connect_upgrade(state: &mut State, widgets: &EventWidgets, is_lts: bool, rebo
}
}
Err(why) => {
error!("failed to fetch EOL date: {}", why);
log::error!("failed to fetch EOL date: {}", why);
None
}
};
Expand Down Expand Up @@ -375,7 +375,7 @@ fn error(state: &mut State, widgets: &EventWidgets, why: UiError) {
.as_str(),
);

error!("{}", error_message);
log::error!("{}", error_message);

if let UiError::Dismiss(dismissed, _) = why {
if let Some(dismisser) = state.dismisser.as_mut() {
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ reorder_impl_items = true
struct_field_align_threshold = 30
use_field_init_shorthand = true
wrap_comments = true
merge_imports = true
imports_granularity = "Crate"
force_multiline_blocks = false
use_small_heuristics = "Max"
2 changes: 1 addition & 1 deletion src/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum ValidateError {
}

pub async fn validate_checksum(file: &mut File, checksum: &str) -> Result<(), ValidateError> {
info!("validating checksum of downloaded ISO");
log::info!("validating checksum of downloaded ISO");
let expected = <[u8; 32]>::from_hex(checksum)
.map(GenericArray::from)
.map_err(|_| ValidateError::InvalidInput)?;
Expand Down
25 changes: 14 additions & 11 deletions src/cli/mod.rs → src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ mod colors;

use self::colors::*;
use crate::notify::notify;

use apt_cmd::AptUpgradeEvent;
use chrono::{TimeZone, Utc};
use clap::ArgMatches;
use fomat_macros::{fomat, pintln};
use num_traits::FromPrimitive;
use pop_upgrade::{
client,
Expand Down Expand Up @@ -38,7 +38,7 @@ const UPGRADE_RESULT_STR: &str = "Release upgrade status";
const UPGRADE_RESULT_SUCCESS: &str = "systems are go for launch: reboot now";
const UPGRADE_RESULT_ERROR: &str = "release upgrade aborted";

#[derive(Shrinkwrap)]
#[derive(shrinkwraprs::Shrinkwrap)]
pub struct Client(client::Client);

impl Client {
Expand Down Expand Up @@ -235,7 +235,7 @@ impl Client {
/// Check if the release has been dismissed by timestamp, or can be.
fn dismiss_by_timestamp(&self, next: &str) -> Result<bool, client::Error> {
if !Path::new(INSTALL_DATE).exists() && installed_after_release(next) {
info!("dismissing notification for the latest release automatically");
log::info!("dismissing notification for the latest release automatically");
let _ = self.dismiss_notification(DismissEvent::ByTimestamp)?;
Ok(true)
} else {
Expand Down Expand Up @@ -294,7 +294,7 @@ impl Client {
if let Ok(event) = AptUpgradeEvent::from_dbus_map(event.into_iter()) {
write_apt_event(event);
} else {
error!("failed to unpack the upgrade event");
log::error!("failed to unpack the upgrade event");
}
}
_ => (),
Expand Down Expand Up @@ -412,7 +412,9 @@ impl Client {
client::Signal::PackageUpgrade(event) => {
match AptUpgradeEvent::from_dbus_map(event.clone().into_iter()) {
Ok(event) => write_apt_event(event),
Err(()) => error!("failed to unpack the upgrade event: {:?}", event),
Err(()) => {
log::error!("failed to unpack the upgrade event: {:?}", event)
}
}
}
client::Signal::ReleaseResult(status) => {
Expand Down Expand Up @@ -481,18 +483,19 @@ fn installed_after_release(next: &str) -> bool {
Ok(codename) => {
return codename.release_timestamp() < install_time as u64
}
Err(()) => error!("version {} is invalid", next),
Err(()) => log::error!("version {} is invalid", next),
}
}
_ => error!(
_ => log::error!(
"major ({}) and minor({}) version failed to parse as u8",
major, minor
major,
minor
),
}
}
None => error!("version {} is invalid", next),
None => log::error!("version {} is invalid", next),
},
Err(why) => error!("failed to get install time: {}", why),
Err(why) => log::error!("failed to get install time: {}", why),
}

false
Expand Down Expand Up @@ -525,7 +528,7 @@ fn notification_message(current: &str, next: &str) -> (String, String) {
}
EolStatus::Ok => (),
},
Err(why) => error!("failed to fetch EOL date: {}", why),
Err(why) => log::error!("failed to fetch EOL date: {}", why),
}

("Upgrade Available".into(), fomat!("Pop!_OS " (next) " is available to download"))
Expand Down
File renamed without changes.
Loading