Skip to content

Commit c400600

Browse files
authored
Merge pull request #11056 from gitbutlerapp/copilot/fix-missing-translation-keys
Add commit date to `but status` base output
2 parents 27e673d + 8d70d89 commit c400600

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

crates/but/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use args::{Args, CommandName, Subcommands, actions, claude, cursor};
77
use but_claude::hooks::OutputAsJson;
88
use but_settings::AppSettings;
99
use colored::Colorize;
10+
use gix::date::time::CustomFormat;
1011
use metrics::{Event, Metrics, Props, metrics_if_configured};
1112

1213
mod base;
@@ -32,6 +33,8 @@ mod status;
3233
mod ui;
3334
mod worktree;
3435

36+
const CLI_DATE: CustomFormat = gix::date::time::format::ISO8601;
37+
3538
/// Handle `args` which must be what's passed by `std::env::args_os()`.
3639
pub async fn handle_args(args: impl Iterator<Item = OsString>) -> Result<()> {
3740
let args: Vec<_> = args.collect();

crates/but/src/status/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::BTreeMap;
22

3+
use crate::CLI_DATE;
34
use assignment::FileAssignment;
45
use bstr::{BString, ByteSlice};
56
use but_core::ui::{TreeChange, TreeStatus};
@@ -8,10 +9,10 @@ use but_settings::AppSettings;
89
use but_workspace::ui::StackDetails;
910
use colored::{ColoredString, Colorize};
1011
use gitbutler_command_context::CommandContext;
11-
use gitbutler_commit::commit_ext::CommitExt;
1212
use gitbutler_oxidize::{ObjectIdExt, OidExt, TimeExt};
1313
use gitbutler_project::Project;
1414
use serde::Serialize;
15+
1516
pub(crate) mod assignment;
1617

1718
use crate::id::CliId;
@@ -24,6 +25,7 @@ struct CommonMergeBase {
2425
target_name: String,
2526
common_merge_base: String,
2627
message: String,
28+
commit_date: String,
2729
}
2830

2931
#[derive(Serialize)]
@@ -81,17 +83,20 @@ pub(crate) async fn worktree(
8183
let target_name = format!("{}/{}", target.branch.remote(), target.branch.branch());
8284
let repo = ctx.gix_repo()?;
8385
let base_commit = repo.find_commit(target.sha.to_gix())?;
86+
let base_commit = base_commit.decode()?;
8487
let message = base_commit
85-
.message_bstr()
88+
.message
8689
.to_string()
8790
.replace('\n', " ")
8891
.chars()
8992
.take(50)
9093
.collect::<String>();
94+
let formatted_date = base_commit.committer().time()?.format_or_unix(CLI_DATE);
9195
let common_merge_base_data = CommonMergeBase {
9296
target_name: target_name.clone(),
9397
common_merge_base: target.sha.to_string()[..7].to_string(),
9498
message: message.clone(),
99+
commit_date: formatted_date,
95100
};
96101

97102
if json {
@@ -131,9 +136,10 @@ pub(crate) async fn worktree(
131136
}
132137
let dot = "●".purple();
133138
println!(
134-
"{dot} {} (common base) [{}] {}",
139+
"{dot} {} (common base) [{}] {} {}",
135140
common_merge_base_data.common_merge_base.dimmed(),
136141
common_merge_base_data.target_name.green().bold(),
142+
common_merge_base_data.commit_date.dimmed(),
137143
common_merge_base_data.message
138144
);
139145
Ok(())
@@ -440,7 +446,7 @@ fn print_commit(
440446

441447
if verbose {
442448
// Verbose format: author and timestamp on first line, message on second line
443-
let formatted_time = created_at.format_or_unix(gix::date::time::format::ISO8601);
449+
let formatted_time = created_at.format_or_unix(CLI_DATE);
444450
println!(
445451
"┊{dot} {}{} {} {} {} {} {} {}",
446452
&commit_id.to_string()[..2].blue().underline(),

crates/but/tests/but/snapshots/from-workspace/status01-verbose.stdout.term.svg

Lines changed: 1 addition & 1 deletion
Loading

crates/but/tests/but/snapshots/from-workspace/status01.stdout.term.svg

Lines changed: 1 addition & 1 deletion
Loading

crates/but/tests/but/status.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ fn json_shows_paths_as_strings() -> anyhow::Result<()> {
175175
"common_merge_base": {
176176
"target_name": "origin/main",
177177
"common_merge_base": "0dc3733",
178-
"message": "add M "
178+
"message": "add M ",
179+
"commit_date": "2000-01-02 00:00:00 +0000"
179180
}
180181
}
181182

0 commit comments

Comments
 (0)