blob: ca699714a75ca13e871613f4e0734496c69c9c8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
use anyhow::Result;
use tracing::{info, warn};
use crate::cache::CacheManager;
pub struct PullCommand;
impl PullCommand {
pub fn new() -> Self {
Self
}
pub async fn execute(&self) -> Result<()> {
info!("Pulling latest offline cache...");
let mut cache_manager = CacheManager::new().await?;
// Update all repositories and rebuild cache indices
match cache_manager.update_all().await {
Ok(_) => {
info!("All caches updated successfully");
}
Err(e) => {
warn!("Cache update completed with some errors: {}", e);
// Try individual updates as fallback
info!("Attempting individual repository updates...");
// Pull SPDX license data
if let Err(e) = cache_manager.update_spdx_cache().await {
warn!("Failed to update SPDX cache: {}", e);
}
// Pull Ruby gems cache
if let Err(e) = cache_manager.update_rubygems_cache().await {
warn!("Failed to update Ruby gems cache: {}", e);
}
// Pull general package cache
if let Err(e) = cache_manager.update_general_cache().await {
warn!("Failed to update general cache: {}", e);
}
}
}
// Display repository status
let status = cache_manager.get_repository_status().await;
info!("Repository status:");
for (name, info) in status {
match info.status {
crate::git::repository::RepositoryStatus::Clean { commit_hash, .. } => {
info!(" {}: ✓ up-to-date ({})", name, &commit_hash[..8]);
}
crate::git::repository::RepositoryStatus::Dirty => {
warn!(" {}: ⚠ has uncommitted changes", name);
}
crate::git::repository::RepositoryStatus::NotCloned => {
warn!(" {}: ✗ not cloned", name);
}
}
}
info!("Cache update complete");
Ok(())
}
}
impl Default for PullCommand {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_pull_command_creation() {
let cmd = PullCommand::new();
// Just ensure we can create the command
assert!(true);
}
#[test]
fn test_pull_command_default() {
let cmd = PullCommand::default();
// Just ensure we can create the command with default
assert!(true);
}
}
|