MCPcopy Create free account
hub / github.com/douglance/devsql / run

Method run

crates/devsql/src/tools/diff.rs:44–333  ·  view source on GitHub ↗
(&self, ctx: CommandContext)

Source from the content-addressed store, hash-verified

42#[async_trait::async_trait]
43impl CommandHandler for DiffHandler {
44 async fn run(&self, ctx: CommandContext) -> CommandResult {
45 let base_ref = match ctx.args.get("base").and_then(|v| v.as_str()) {
46 Some(r) => r.to_string(),
47 None => {
48 return CommandResult::Error {
49 code: "MISSING_ARG".into(),
50 message: "Missing required argument: base".into(),
51 retryable: false,
52 exit_code: Some(1),
53 cta: None,
54 };
55 }
56 };
57
58 let head_ref = match ctx.args.get("head").and_then(|v| v.as_str()) {
59 Some(r) => r.to_string(),
60 None => {
61 return CommandResult::Error {
62 code: "MISSING_ARG".into(),
63 message: "Missing required argument: head".into(),
64 retryable: false,
65 exit_code: Some(1),
66 cta: None,
67 };
68 }
69 };
70
71 let repo_str = ctx
72 .options
73 .get("repo")
74 .and_then(|v| v.as_str())
75 .unwrap_or(".");
76 let limit = ctx
77 .options
78 .get("limit")
79 .and_then(|v| v.as_i64())
80 .unwrap_or(100) as usize;
81
82 let repo_path = if repo_str == "." {
83 match std::env::current_dir() {
84 Ok(p) => p,
85 Err(e) => {
86 return CommandResult::Error {
87 code: "PATH_ERROR".into(),
88 message: format!("Cannot determine current directory: {e}"),
89 retryable: false,
90 exit_code: Some(1),
91 cta: None,
92 };
93 }
94 }
95 } else {
96 PathBuf::from(repo_str)
97 };
98
99 let repo = match git2::Repository::open(&repo_path) {
100 Ok(r) => r,
101 Err(e) => {

Callers

nothing calls this directly

Calls 4

detect_languageFunction · 0.85
read_file_at_commitFunction · 0.85
diff_file_symbolsFunction · 0.85
pathMethod · 0.80

Tested by

no test coverage detected