Skip to content

Commit ceb8976

Browse files
committed
build: bump edition
1 parent f57eb85 commit ceb8976

File tree

6 files changed

+53
-63
lines changed

6 files changed

+53
-63
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
name = "workset"
33
description = "Manage git repos with worksets"
44
version = "0.1.0"
5-
edition = "2021"
5+
edition = "2024"
66
authors = ["cilki"]
77
repository = "https://github.com/fossable/workset/"
88
readme = "README.md"
9+
license = "Unlicense"
910
keywords = ["git", "workspace", "cli", "repository", "manager"]
1011
categories = ["command-line-utilities", "development-tools"]
1112

src/lib.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{bail, Result};
1+
use anyhow::{Result, bail};
22
use cmd_lib::run_fun;
33
use remote::{ListRepos, Remote};
44
use serde::{Deserialize, Serialize};
@@ -205,16 +205,14 @@ pub fn check_uncommitted_changes(repo_path: &Path) -> Result<bool> {
205205
{
206206
Ok(mut iter) => {
207207
// Check if there are any untracked files
208-
for item in iter.by_ref() {
209-
if let Ok(entry) = item {
210-
// Check if this is an untracked file
211-
if matches!(
212-
entry,
213-
gix::status::index_worktree::iter::Item::DirectoryContents { .. }
214-
) {
215-
debug!("Repository has untracked files: {}", repo_path.display());
216-
return Ok(true);
217-
}
208+
for entry in iter.by_ref().flatten() {
209+
// Check if this is an untracked file
210+
if matches!(
211+
entry,
212+
gix::status::index_worktree::iter::Item::DirectoryContents { .. }
213+
) {
214+
debug!("Repository has untracked files: {}", repo_path.display());
215+
return Ok(true);
218216
}
219217
}
220218
}
@@ -399,15 +397,6 @@ impl Workspace {
399397
/// Search the workspace for local repos matching the given pattern.
400398
pub fn search(&self, pattern: &RepoPattern) -> Result<Vec<PathBuf>> {
401399
let repos = find_git_repositories(&format!("{}/{}", self.path, pattern.full_path()))?;
402-
403-
// Try each remote if there were no matches immediately
404-
// if repos.len() == 0 {
405-
// for remote in self.remotes.iter() {
406-
// let repos = find_git_dir(&format!("{}/{}/{}", self.path, remote.name(), pattern.full_path()))?;
407-
// if repos.len() == 0 {}
408-
// }
409-
// }
410-
411400
Ok(repos)
412401
}
413402

@@ -651,7 +640,7 @@ impl Library {
651640
let dest = self.compute_library_key(&repo_path);
652641

653642
// Verify the source .git directory exists
654-
if !std::fs::metadata(&source).is_ok() {
643+
if std::fs::metadata(&source).is_err() {
655644
bail!("Repository .git directory not found: {}", source);
656645
}
657646

@@ -677,7 +666,7 @@ impl Library {
677666
let source = self.compute_library_key(&repo_path);
678667

679668
// Verify the library entry exists
680-
if !std::fs::metadata(&source).is_ok() {
669+
if std::fs::metadata(&source).is_err() {
681670
bail!("Repository not found in library for path: {}", repo_path);
682671
}
683672

src/main.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use anyhow::Result;
22
use std::io::Write;
33
use tracing::level_filters::LevelFilter;
44
use tracing::{error, info};
5-
use workset::remote::ListRepos;
65
use workset::Workspace;
6+
use workset::remote::ListRepos;
77

88
/// Build info provided by built crate.
99
pub mod build_info {
@@ -55,14 +55,14 @@ fn main() -> Result<()> {
5555
println!(" <pattern> Add a repository to your working set");
5656
println!(" drop [pattern] [--delete] [--force] Drop repository(ies) from workspace");
5757
println!(
58-
" Without pattern: drops all in current directory"
59-
);
58+
" Without pattern: drops all in current directory"
59+
);
6060
println!(
61-
" With --delete: permanently delete (don't store)"
62-
);
61+
" With --delete: permanently delete (don't store)"
62+
);
6363
println!(
64-
" With --force: drop even with uncommitted changes"
65-
);
64+
" With --force: drop even with uncommitted changes"
65+
);
6666
println!(" list, ls List all repositories with their status");
6767
println!(" status Show workspace summary and statistics");
6868
println!();
@@ -144,14 +144,11 @@ fn main() -> Result<()> {
144144
{
145145
if let Some(workspace) = maybe_workspace {
146146
// Open TUI for interactive repository selection
147-
match workset::tui::run_tui(&workspace)? {
148-
Some(repo) => {
149-
let pattern: workset::RepoPattern = repo
150-
.parse()
151-
.map_err(|e| anyhow::anyhow!("Failed to parse pattern: {}", e))?;
152-
workspace.open(workspace.library.as_ref(), &pattern)?;
153-
}
154-
None => (),
147+
if let Some(repo) = workset::tui::run_tui(&workspace)? {
148+
let pattern: workset::RepoPattern = repo
149+
.parse()
150+
.map_err(|e| anyhow::anyhow!("Failed to parse pattern: {}", e))?;
151+
workspace.open(workspace.library.as_ref(), &pattern)?;
155152
}
156153
} else {
157154
error!("You're not in a workspace");
@@ -339,9 +336,9 @@ fn complete_fish(maybe_workspace: Option<Workspace>) -> Result<()> {
339336
#[cfg(test)]
340337
mod tests {
341338
use super::*;
339+
use workset::Workspace;
342340
#[cfg(feature = "github")]
343341
use workset::remote::github::GithubRemote;
344-
use workset::Workspace;
345342

346343
#[test]
347344
#[cfg(feature = "github")]

src/remote/github.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ impl ListRepos for GithubRemote {
3939
let output = run_fun!(
4040
gh repo list $user --json nameWithOwner,isFork,isArchived --limit 1000
4141
)
42-
.context("Failed to run 'gh' command. Make sure GitHub CLI is installed and authenticated")?;
42+
.context(
43+
"Failed to run 'gh' command. Make sure GitHub CLI is installed and authenticated",
44+
)?;
4345

4446
// Parse JSON output
45-
let repos: Vec<GithubRepo> = serde_json::from_str(&output)
46-
.context("Failed to parse gh CLI output")?;
47+
let repos: Vec<GithubRepo> =
48+
serde_json::from_str(&output).context("Failed to parse gh CLI output")?;
4749

4850
let mut all_repos = Vec::new();
4951

@@ -111,8 +113,9 @@ mod tests {
111113
"user": "testuser",
112114
"include_forks": true,
113115
"include_archived": true
114-
}"#
115-
).unwrap();
116+
}"#,
117+
)
118+
.unwrap();
116119
assert_eq!(remote.user, "testuser");
117120
assert!(remote.include_forks);
118121
assert!(remote.include_archived);

src/remote/gitlab.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ impl fmt::Display for GitlabRemote {
3333

3434
impl Metadata for GitlabRemote {
3535
fn name(&self) -> String {
36-
let domain = self.url
36+
let domain = self
37+
.url
3738
.strip_prefix("https://")
3839
.or_else(|| self.url.strip_prefix("http://"))
3940
.unwrap_or(&self.url);
@@ -46,7 +47,8 @@ impl ListRepos for GitlabRemote {
4647
use cmd_lib::run_fun;
4748

4849
// Get domain for formatting paths
49-
let domain = self.url
50+
let domain = self
51+
.url
5052
.strip_prefix("https://")
5153
.or_else(|| self.url.strip_prefix("http://"))
5254
.unwrap_or(&self.url);
@@ -65,7 +67,9 @@ impl ListRepos for GitlabRemote {
6567
glab repo list --member --per-page 100
6668
)
6769
}
68-
.context("Failed to run 'glab' command. Make sure GitLab CLI is installed and authenticated")?;
70+
.context(
71+
"Failed to run 'glab' command. Make sure GitLab CLI is installed and authenticated",
72+
)?;
6973

7074
// Parse the output - glab returns tab-separated values by default
7175
// Format: namespace/project\tdescription\t...
@@ -160,8 +164,9 @@ mod tests {
160164
"url": "https://custom.gitlab.com",
161165
"include_forks": true,
162166
"include_archived": true
163-
}"#
164-
).unwrap();
167+
}"#,
168+
)
169+
.unwrap();
165170
assert_eq!(remote.user, "testuser");
166171
assert_eq!(remote.url, "https://custom.gitlab.com");
167172
assert!(remote.include_forks);

src/tui.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use anyhow::Result;
33
use crossterm::{
44
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
55
execute,
6-
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
6+
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
77
};
88
use ratatui::{
9+
Frame, Terminal,
910
backend::CrosstermBackend,
1011
layout::{Constraint, Direction, Layout},
1112
style::{Color, Modifier, Style},
1213
text::{Line, Span},
1314
widgets::{Block, Borders, List, ListItem, ListState, Paragraph},
14-
Frame, Terminal,
1515
};
1616
use std::io;
1717

@@ -53,10 +53,7 @@ impl App {
5353
self.filtered_repos = self
5454
.repos
5555
.iter()
56-
.filter(|r| {
57-
r.to_lowercase()
58-
.contains(&self.search_query.to_lowercase())
59-
})
56+
.filter(|r| r.to_lowercase().contains(&self.search_query.to_lowercase()))
6057
.cloned()
6158
.collect();
6259
}
@@ -228,17 +225,15 @@ fn ui(f: &mut Frame, app: &mut App) {
228225
let items: Vec<ListItem> = app
229226
.filtered_repos
230227
.iter()
231-
.map(|repo| {
232-
ListItem::new(Line::from(vec![Span::raw(repo)]))
233-
})
228+
.map(|repo| ListItem::new(Line::from(vec![Span::raw(repo)])))
234229
.collect();
235230

236231
let items = List::new(items)
237-
.block(
238-
Block::default()
239-
.borders(Borders::ALL)
240-
.title(format!("Repositories ({}/{})", app.filtered_repos.len(), app.repos.len())),
241-
)
232+
.block(Block::default().borders(Borders::ALL).title(format!(
233+
"Repositories ({}/{})",
234+
app.filtered_repos.len(),
235+
app.repos.len()
236+
)))
242237
.highlight_style(
243238
Style::default()
244239
.bg(Color::DarkGray)

0 commit comments

Comments
 (0)