Skip to content

Commit bc611bc

Browse files
author
Stephan Dilly
committed
allow inspecting top commit in branchlist
1 parent 6abc7d2 commit bc611bc

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
![name-validation](assets/branch-validation.gif)
2121

2222
## Added
23+
- allow opening top commit of a branch
2324
- new options popup (show untracked files, diff settings) ([#849](https://github.com/extrawurst/gitui/issues/849))
2425
- mark and drop multiple stashes ([#854](https://github.com/extrawurst/gitui/issues/854))
2526
- check branch name validity while typing ([#559](https://github.com/extrawurst/gitui/issues/559))

src/components/blame_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl Component for BlameFileComponent {
166166
);
167167
out.push(
168168
CommandInfo::new(
169-
strings::commands::log_details_open(
169+
strings::commands::commit_details_open(
170170
&self.key_config,
171171
),
172172
true,

src/components/branchlist.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use anyhow::Result;
1414
use asyncgit::{
1515
sync::{
1616
self, branch::checkout_remote_branch, checkout_branch,
17-
get_branches_info, BranchInfo,
17+
get_branches_info, BranchInfo, CommitId,
1818
},
1919
AsyncGitNotification, CWD,
2020
};
@@ -118,6 +118,14 @@ impl Component for BranchListComponent {
118118
true,
119119
));
120120

121+
out.push(CommandInfo::new(
122+
strings::commands::commit_details_open(
123+
&self.key_config,
124+
),
125+
true,
126+
true,
127+
));
128+
121129
out.push(CommandInfo::new(
122130
strings::commands::toggle_branch_popup(
123131
&self.key_config,
@@ -192,6 +200,9 @@ impl Component for BranchListComponent {
192200
return self
193201
.move_selection(ScrollType::PageUp)
194202
.map(Into::into);
203+
} else if e == self.key_config.tab_toggle {
204+
self.local = !self.local;
205+
self.update_branches()?;
195206
} else if e == self.key_config.enter {
196207
try_or_popup!(
197208
self,
@@ -234,13 +245,18 @@ impl Component for BranchListComponent {
234245
"merge branch error:",
235246
self.merge_branch()
236247
);
237-
self.hide();
238248
self.queue.push(InternalEvent::Update(
239249
NeedsUpdate::ALL,
240250
));
241-
} else if e == self.key_config.tab_toggle {
242-
self.local = !self.local;
243-
self.update_branches()?;
251+
} else if e == self.key_config.move_right
252+
&& self.valid_selection()
253+
{
254+
self.hide();
255+
if let Some(b) = self.get_selected() {
256+
self.queue.push(
257+
InternalEvent::InspectCommit(b, None),
258+
);
259+
}
244260
}
245261
}
246262

@@ -351,6 +367,12 @@ impl BranchListComponent {
351367
.count() > 0
352368
}
353369

370+
fn get_selected(&self) -> Option<CommitId> {
371+
self.branches
372+
.get(usize::from(self.selection))
373+
.map(|b| b.top_commit)
374+
}
375+
354376
///
355377
fn move_selection(&mut self, scroll: ScrollType) -> Result<bool> {
356378
let new_selection = match scroll {

src/strings.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,8 @@ pub mod commands {
929929
CMD_GROUP_LOG,
930930
)
931931
}
932-
pub fn log_details_open(
932+
933+
pub fn commit_details_open(
933934
key_config: &SharedKeyConfig,
934935
) -> CommandText {
935936
CommandText::new(
@@ -938,9 +939,10 @@ pub mod commands {
938939
key_config.get_hint(key_config.focus_right),
939940
),
940941
"inspect selected commit in detail",
941-
CMD_GROUP_LOG,
942+
CMD_GROUP_GENERAL,
942943
)
943944
}
945+
944946
pub fn blame_file(key_config: &SharedKeyConfig) -> CommandText {
945947
CommandText::new(
946948
format!(

src/tabs/revlog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl Component for Revlog {
292292
));
293293

294294
out.push(CommandInfo::new(
295-
strings::commands::log_details_open(&self.key_config),
295+
strings::commands::commit_details_open(&self.key_config),
296296
true,
297297
(self.visible && self.commit_details.is_visible())
298298
|| force_all,

0 commit comments

Comments
 (0)