Skip to content

Commit 9d7227f

Browse files
heiskaneIndianBoy42
authored andcommitted
file blame at right revision from commit-details (gitui-org#1324)
1 parent baa166d commit 9d7227f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
* customizable `cmdbar_bg` theme color & screen spanning selected line bg [[@gigitsu](https://github.com/gigitsu)] ([#1299](https://github.com/extrawurst/gitui/pull/1299))
1717
* use filewatcher instead of polling updates ([#1](https://github.com/extrawurst/gitui/issues/1))
1818
* word motions to text input [[@Rodrigodd](https://github.com/Rodrigodd)] ([#1256](https://github.com/extrawurst/gitui/issues/1256))
19+
* file blame at right revision from commit-details [[@heiskane](https://github.com/heiskane)] ([#1122](https://github.com/extrawurst/gitui/issues/1122))
1920

2021
### Fixes
2122
* remove insecure dependency `ansi_term` ([#1290](https://github.com/extrawurst/gitui/issues/1290))

src/components/commit_details/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ impl CommitDetailsComponent {
102102
self.commit = params;
103103

104104
if let Some(id) = params {
105+
self.file_tree.set_commit(Some(id.id));
106+
105107
if let Some(other) = id.other {
106108
self.compare_details
107109
.set_commits(Some((id.id, other)));

src/components/status_tree.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
ui::style::SharedTheme,
1515
};
1616
use anyhow::Result;
17-
use asyncgit::{hash, StatusItem, StatusItemType};
17+
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
1818
use crossterm::event::Event;
1919
use std::{borrow::Cow, cell::Cell, convert::From, path::Path};
2020
use tui::{backend::Backend, layout::Rect, text::Span, Frame};
@@ -35,6 +35,7 @@ pub struct StatusTreeComponent {
3535
key_config: SharedKeyConfig,
3636
scroll_top: Cell<usize>,
3737
visible: bool,
38+
revision: Option<CommitId>,
3839
}
3940

4041
impl StatusTreeComponent {
@@ -58,9 +59,14 @@ impl StatusTreeComponent {
5859
scroll_top: Cell::new(0),
5960
pending: true,
6061
visible: false,
62+
revision: None,
6163
}
6264
}
6365

66+
pub fn set_commit(&mut self, revision: Option<CommitId>) {
67+
self.revision = revision;
68+
}
69+
6470
///
6571
pub fn update(&mut self, list: &[StatusItem]) -> Result<()> {
6672
self.pending = false;
@@ -428,7 +434,7 @@ impl Component for StatusTreeComponent {
428434
StackablePopupOpen::BlameFile(
429435
BlameFileOpen {
430436
file_path: status_item.path,
431-
commit_id: None,
437+
commit_id: self.revision,
432438
selection: None,
433439
},
434440
),

0 commit comments

Comments
 (0)