🔄 Update script metadata and enhance git commit logic with AI summarization
解释:
1. 🔄 表示更新/修改类型的变化
2. 核心变更包括:
- 更新了 script-meta-v2.json 和 script-meta.json 中的脚本元数据(长度、哈希值、更新时间等)
- 修改了 sync-rs/src/main.rs 的文件权限(从 644 改为 755)
- 增强了 git commit 逻辑,加入了 AI 自动生成提交信息的功能
3. 总结突出了变更的核心内容,即元数据更新和提交逻辑的改进
This commit is contained in:
@@ -138,11 +138,11 @@
|
|||||||
},
|
},
|
||||||
"sync.rs": {
|
"sync.rs": {
|
||||||
"script_name": "sync.rs",
|
"script_name": "sync.rs",
|
||||||
"script_length": 1978,
|
"script_length": 2973,
|
||||||
"script_sha256": "2218487f955e8021c2e4b5b56b9aa4bec6cde89839ae45449bb852c5696cb72e",
|
"script_sha256": "a94a20258431e8dd7534e1078f9894de799a220f99b993ba9f2e56dc760804ea",
|
||||||
"script_full_url": "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/sync-rs/src/main.rs",
|
"script_full_url": "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/sync-rs/src/main.rs",
|
||||||
"publish_time": 1737272563310,
|
"publish_time": 1737272563310,
|
||||||
"update_time": 1750428425867
|
"update_time": 1775318648698
|
||||||
},
|
},
|
||||||
"xattr.rs": {
|
"xattr.rs": {
|
||||||
"script_name": "xattr.rs",
|
"script_name": "xattr.rs",
|
||||||
|
|||||||
@@ -81,8 +81,8 @@
|
|||||||
},
|
},
|
||||||
"sync-rs": {
|
"sync-rs": {
|
||||||
"script_name": "sync-rs",
|
"script_name": "sync-rs",
|
||||||
"script_length": 1978,
|
"script_length": 2973,
|
||||||
"script_sha256": "2218487f955e8021c2e4b5b56b9aa4bec6cde89839ae45449bb852c5696cb72e"
|
"script_sha256": "a94a20258431e8dd7534e1078f9894de799a220f99b993ba9f2e56dc760804ea"
|
||||||
},
|
},
|
||||||
"xattr-rs": {
|
"xattr-rs": {
|
||||||
"script_name": "xattr-rs",
|
"script_name": "xattr-rs",
|
||||||
|
|||||||
38
sync-rs/src/main.rs
Normal file → Executable file
38
sync-rs/src/main.rs
Normal file → Executable file
@@ -9,7 +9,7 @@ use std::env;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use rust_util::{failure_and_exit, information, success, warning};
|
use rust_util::{failure, failure_and_exit, information, success, warning};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
if let Some(args_1) = env::args().nth(1) {
|
if let Some(args_1) = env::args().nth(1) {
|
||||||
@@ -27,7 +27,29 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
information!("Git Add All");
|
information!("Git Add All");
|
||||||
Command::new("git").args(&["add", "."]).spawn()?.wait()?;
|
Command::new("git").args(&["add", "."]).spawn()?.wait()?;
|
||||||
information!("Git Commit All");
|
information!("Git Commit All");
|
||||||
Command::new("git").args(&["commit", "-a", "-m", "'auto sync'"]).spawn()?.wait()?;
|
information!("AI summarizing...");
|
||||||
|
let ai_summarize_output = Command::new("sh")
|
||||||
|
.args(&["-c", r##"xh --ignore-stdin https://hatter.ink/ai/commit-summarize.json -f "Authorization:Bearer $(get-secret.ts --id ai-commit-summarize-token)" gitStatus="$(git status)" gitDiff="$(git diff)" | jq .data.summary -r"##])
|
||||||
|
.output()?;
|
||||||
|
let mut message = "auto sync".to_string();
|
||||||
|
information!("{:?}", ai_summarize_output);
|
||||||
|
if ai_summarize_output.status.success() {
|
||||||
|
if let Ok(summarized_message) = String::from_utf8(ai_summarize_output.stdout) {
|
||||||
|
success!("AI summarized message: {}", summarized_message);
|
||||||
|
message = summarized_message;
|
||||||
|
} else {
|
||||||
|
warning!("AI summarized message is not UTF-8");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
failure!(
|
||||||
|
"AI summarize failed, status: {}",
|
||||||
|
ai_summarize_output.status
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Command::new("git")
|
||||||
|
.args(&["commit", "-a", "-m", &message])
|
||||||
|
.spawn()?
|
||||||
|
.wait()?;
|
||||||
information!("Git Push");
|
information!("Git Push");
|
||||||
Command::new("git").args(&["push"]).spawn()?.wait()?;
|
Command::new("git").args(&["push"]).spawn()?.wait()?;
|
||||||
information!("Sync Server Repo");
|
information!("Sync Server Repo");
|
||||||
@@ -52,11 +74,15 @@ pub fn find_parents_exists_dir(dir: &str) -> Option<PathBuf> {
|
|||||||
match PathBuf::from(".").canonicalize() {
|
match PathBuf::from(".").canonicalize() {
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
Ok(mut path) => loop {
|
Ok(mut path) => loop {
|
||||||
if path.join(dir).is_dir() { return Some(path); }
|
if path.join(dir).is_dir() {
|
||||||
if !path.pop() { return None; }
|
return Some(path);
|
||||||
}
|
}
|
||||||
|
if !path.pop() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20250620T220543+08:00.MEUCIHsFQ1sf53x3ATTLFkMQ
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260405T000314+08:00.MEYCIQCOflkXKihoc6wfiGml
|
||||||
// oUau9y550grtnm7yGglEoDI/AiEAgZcouLIJXHP042IFnhkTljMo67O9Cs6MlpvNT+BzOA8=
|
// TObfzEuzkqKg3yEfU+swKk7aJgIhALHUGopxnHNXjSoWziiQt9U1xb8qGpamrsHdd20nrTjx
|
||||||
|
|||||||
Reference in New Issue
Block a user