GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — clibrowser/cligit/src/commands/show.rs at main · allthingssecurity/clibrowser Expand file tree/ Copy pathshow.rsMore file actions 68 lines (61 loc) · 2.35 KB / Copy pathshow.rsFile metadata and controls68 lines (61 loc) · 2.35 KB 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 use anyhow::Result; use chrono::DateTime; use crate::cli::ShowArgs; use crate::git_ctx::GitContext; use crate::models::*; use crate::output::OutputConfig; use crate::commands::diff::parse_diff; pub fn execute(args: ShowArgs, ctx: &GitContext, out: &OutputConfig) -> Result<i32> { let repo = &ctx.repo; let obj = repo.revparse_single(&args.r#ref)?; let commit = obj.peel_to_commit()?; let sha = commit.id().to_string(); let tree = commit.tree()?; let diff = if commit.parent_count() > 0 { let parent_tree = commit.parent(0)?.tree()?; repo.diff_tree_to_tree(Some(&parent_tree), Some(&tree), None)? } else { repo.diff_tree_to_tree(None, Some(&tree), None)? }; let (files, stats) = parse_diff(&diff, args.stat); let msg = commit.message().unwrap_or("").to_string(); let (first_line, body) = { let t = msg.trim(); if let Some(i) = t.find('\n') { (t[..i].trim().to_string(), { let r = t[i+1..].trim().to_string(); if r.is_empty() { None } else { Some(r) } }) } else { (t.to_string(), None) } }; let parents: Vec<String> = commit.parent_ids().map(|p| p.to_string()).collect(); let date = DateTime::from_timestamp(commit.time().seconds(), 0) .map(|d| d.to_rfc3339()).unwrap_or_default(); let result = ShowResult { short_sha: sha[..7.min(sha.len())].to_string(), sha, message: first_line, body, author: AuthorInfo { name: commit.author().name().unwrap_or("").to_string(), email: commit.author().email().unwrap_or("").to_string(), }, committer: AuthorInfo { name: commit.committer().name().unwrap_or("").to_string(), email: commit.committer().email().unwrap_or("").to_string(), }, date, parents, stats, files, }; if out.json { out.print_json(&result); } else { out.print_human(&format!("commit {}", result.sha)); out.print_human(&format!("Author: {} <{}>", result.author.name, result.author.email)); out.print_human(&format!("Date: {}", result.date)); out.print_human(&format!("\n {}", result.message)); out.print_human(&format!("\n {} file(s), +{} -{}", result.stats.files_changed, result.stats.additions, result.stats.deletions)); } Ok(0) } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |