-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
use crate::cmd::RepoPattern; | ||
use crate::Config; | ||
use anyhow::Result; | ||
use anyhow::{bail, Result}; | ||
use cmd_lib::*; | ||
use tracing::debug; | ||
|
||
/// Open one or more repositories in the workspace | ||
pub fn run_open(config: &Config, path: Option<String>) -> Result<()> { | ||
debug!("Open requested for: {:?}", &path); | ||
let path = match path { | ||
Some(path) => path, | ||
None => bail!("No pattern given"), | ||
}; | ||
|
||
let pattern = match str::parse::<RepoPattern>(&path) { | ||
Ok(pattern) => pattern, | ||
Err(_) => bail!("Failed to parse pattern"), | ||
}; | ||
|
||
// Check the cache first | ||
if let Some(cache) = &config.cache {} | ||
debug!(pattern = ?pattern, "Opening repos"); | ||
|
||
// Check the cache | ||
if let Some(cache) = &config.cache { | ||
// TODO cache.search | ||
} | ||
|
||
let repos = match path { | ||
Some(p) => config.resolve_local(&RepoPattern::parse(&p)?), // TODO remote | ||
Some(p) => config.search_local(&RepoPattern::parse(&p)?), // TODO remote | ||
None => Vec::new(), | ||
}; | ||
|
||
for repo in repos { | ||
let out = run_fun!(git -C $repo status --porcelain)?; | ||
println!("{}", out); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters