Skip to content

Commit

Permalink
file blame at right revision from commit-details (extrawurst#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
heiskane authored and IndianBoy42 committed Jun 4, 2024
1 parent baa166d commit 9d7227f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* customizable `cmdbar_bg` theme color & screen spanning selected line bg [[@gigitsu](https://github.com/gigitsu)] ([#1299](https://github.com/extrawurst/gitui/pull/1299))
* use filewatcher instead of polling updates ([#1](https://github.com/extrawurst/gitui/issues/1))
* word motions to text input [[@Rodrigodd](https://github.com/Rodrigodd)] ([#1256](https://github.com/extrawurst/gitui/issues/1256))
* file blame at right revision from commit-details [[@heiskane](https://github.com/heiskane)] ([#1122](https://github.com/extrawurst/gitui/issues/1122))

### Fixes
* remove insecure dependency `ansi_term` ([#1290](https://github.com/extrawurst/gitui/issues/1290))
Expand Down
2 changes: 2 additions & 0 deletions src/components/commit_details/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ impl CommitDetailsComponent {
self.commit = params;

if let Some(id) = params {
self.file_tree.set_commit(Some(id.id));

if let Some(other) = id.other {
self.compare_details
.set_commits(Some((id.id, other)));
Expand Down
10 changes: 8 additions & 2 deletions src/components/status_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
ui::style::SharedTheme,
};
use anyhow::Result;
use asyncgit::{hash, StatusItem, StatusItemType};
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
use crossterm::event::Event;
use std::{borrow::Cow, cell::Cell, convert::From, path::Path};
use tui::{backend::Backend, layout::Rect, text::Span, Frame};
Expand All @@ -35,6 +35,7 @@ pub struct StatusTreeComponent {
key_config: SharedKeyConfig,
scroll_top: Cell<usize>,
visible: bool,
revision: Option<CommitId>,
}

impl StatusTreeComponent {
Expand All @@ -58,9 +59,14 @@ impl StatusTreeComponent {
scroll_top: Cell::new(0),
pending: true,
visible: false,
revision: None,
}
}

pub fn set_commit(&mut self, revision: Option<CommitId>) {
self.revision = revision;
}

///
pub fn update(&mut self, list: &[StatusItem]) -> Result<()> {
self.pending = false;
Expand Down Expand Up @@ -428,7 +434,7 @@ impl Component for StatusTreeComponent {
StackablePopupOpen::BlameFile(
BlameFileOpen {
file_path: status_item.path,
commit_id: None,
commit_id: self.revision,
selection: None,
},
),
Expand Down

0 comments on commit 9d7227f

Please sign in to comment.