Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
- name: Check
run: cargo check --verbose

- name: Format
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy -- -D warnings

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ See [docs/architecture.md](docs/architecture.md) for the full layout. Short vers

### Style

- Rust edition 2021, `cargo fmt` before commit (`rustfmt.toml` is committed).
- Rust edition 2021, `cargo fmt` before commit (default rustfmt config; CI enforces `cargo fmt --check`).
- Prefer small focused commits with [Conventional Commits](https://www.conventionalcommits.org) prefixes (`feat:`, `fix:`, `docs:`, `refactor:`, `chore:`, `ci:`) so release-please can detect release-worthy changes and bump versions automatically.
- Keep platform-specific code behind `#[cfg(target_os = "...")]` so every platform still compiles.
- If you touch the public `colony.json` schema, also update [docs/colony-spec.md](docs/colony-spec.md) in the same PR.
Expand Down
10 changes: 6 additions & 4 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::path::PathBuf;

use crate::ui::TutorialBounds;

use crate::github::ColonyRepo;
use crate::oauth::OAuthSession;
use crate::scan::Application;
use crate::state::DetailTab;
use crate::github::ColonyRepo;

#[derive(Debug, Clone)]
pub enum Message {
Expand All @@ -31,9 +31,9 @@ pub enum Message {
GitHubReposFetched(Vec<ColonyRepo>),
GitHubError(String),
GitHubRefreshRepos,
DownloadRelease(String, String), // (repo_name, platform_key)
DownloadRelease(String, String), // (repo_name, platform_key)
#[allow(dead_code)]
DownloadProgress(String, f32), // (filename, progress 0.0..1.0)
DownloadProgress(String, f32), // (filename, progress 0.0..1.0)
DownloadCompleted(Result<(PathBuf, String, String), String>), // (path, repo_name, tag)
CancelDownload,
LaunchColonyApp(PathBuf),
Expand Down Expand Up @@ -84,7 +84,9 @@ pub enum Message {
/// manual check gets an "up to date" toast (an automatic one would toast
/// on every boot) and network failures surface as errors instead of the
/// check lying that Colony is current.
CheckLauncherUpdate { manual: bool },
CheckLauncherUpdate {
manual: bool,
},
/// (manual, result of the check). Ok(None) = genuinely up to date;
/// Err = the check could not run (network/rate limit/bad tag).
LauncherUpdateChecked(bool, Result<Option<(String, String)>, String>),
Expand Down
19 changes: 11 additions & 8 deletions src/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ pub async fn request_device_code() -> Result<DeviceCode> {

let device: DeviceCodeResponse = resp.json().await?;

tracing::info!("Enter code {} at {}", device.user_code, device.verification_uri);
tracing::info!(
"Enter code {} at {}",
device.user_code,
device.verification_uri
);

// Open browser with pre-filled user code
let url = format!(
"{}?user_code={}",
device.verification_uri, device.user_code
);
let url = format!("{}?user_code={}", device.verification_uri, device.user_code);
let _ = open::that(&url);

Ok(DeviceCode {
Expand All @@ -93,8 +94,7 @@ pub async fn poll_for_token(device: DeviceCode) -> Result<OAuthSession> {
.unwrap_or_else(|_| reqwest::Client::new());

let poll_interval = Duration::from_secs(device.interval.max(5));
let deadline =
std::time::Instant::now() + Duration::from_secs(device.expires_in);
let deadline = std::time::Instant::now() + Duration::from_secs(device.expires_in);

let access_token = loop {
tokio::time::sleep(poll_interval).await;
Expand Down Expand Up @@ -188,7 +188,10 @@ fn token_path() -> PathBuf {
}
Err(_) => {
let base = dirs::config_dir().unwrap_or_else(|| PathBuf::from("."));
base.join("Colony").join("Colony").join("auth").join("github_token.json")
base.join("Colony")
.join("Colony")
.join("auth")
.join("github_token.json")
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ pub fn save_installed_version(repo_name: &str, tag: &str) -> Result<()> {
/// Load the installed version tag for a repo.
pub fn load_installed_version(repo_name: &str) -> Option<String> {
let path = colony_apps_dir().ok()?.join(repo_name).join(VERSION_FILE);
std::fs::read_to_string(path).ok().map(|s| s.trim().to_string())
std::fs::read_to_string(path)
.ok()
.map(|s| s.trim().to_string())
}

/// Save the resolved asset name for a repo (when using filePattern).
Expand All @@ -128,7 +130,9 @@ pub fn save_installed_asset(repo_name: &str, filename: &str) -> Result<()> {
/// Load the saved resolved asset name for a repo.
pub fn load_installed_asset(repo_name: &str) -> Option<String> {
let path = colony_apps_dir().ok()?.join(repo_name).join(ASSET_FILE);
std::fs::read_to_string(path).ok().map(|s| s.trim().to_string())
std::fs::read_to_string(path)
.ok()
.map(|s| s.trim().to_string())
}

fn repos_cache_path() -> Result<PathBuf> {
Expand Down Expand Up @@ -285,7 +289,7 @@ pub fn save_scan_cache(apps: &[CachedApp]) -> Result<()> {
mod tests {
use super::*;

#[test]
#[test]
fn colony_apps_dir_returns_path() {
let dir = colony_apps_dir();
assert!(dir.is_ok());
Expand Down
Loading
Loading