mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
show tags in commit details popup (closes #193)
This commit is contained in:
parent
f4e2b7c6c0
commit
1afa91b144
10 changed files with 58 additions and 26 deletions
|
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- crashes in revlog with utf8 commit messages ([#188](https://github.com/extrawurst/gitui/issues/188))
|
||||
- `add_to_ignore` failed on files without a newline at EOF ([#191](https://github.com/extrawurst/gitui/issues/191))
|
||||
- new tags were not picked up in revlog view ([#190](https://github.com/extrawurst/gitui/issues/190))
|
||||
- tags not shown in commit details popup ([#193](https://github.com/extrawurst/gitui/issues/193))
|
||||
|
||||
## [0.8.1] - 2020-07-07
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub use ignore::add_to_ignore;
|
|||
pub use logwalker::LogWalker;
|
||||
pub use reset::{reset_stage, reset_workdir};
|
||||
pub use stash::{get_stashes, stash_apply, stash_drop, stash_save};
|
||||
pub use tags::{get_tags, Tags};
|
||||
pub use tags::{get_tags, CommitTags, Tags};
|
||||
pub use utils::{
|
||||
get_head, is_bare_repo, is_repo, stage_add_all, stage_add_file,
|
||||
stage_addremoved,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ use crate::error::Result;
|
|||
use scopetime::scope_time;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// all tags pointing to a single commit
|
||||
pub type CommitTags = Vec<String>;
|
||||
/// hashmap of tag target commit hash to tag names
|
||||
pub type Tags = BTreeMap<CommitId, Vec<String>>;
|
||||
pub type Tags = BTreeMap<CommitId, CommitTags>;
|
||||
|
||||
/// returns `Tags` type filled with all tags found in repo
|
||||
pub fn get_tags(repo_path: &str) -> Result<Tags> {
|
||||
|
|
|
|||
|
|
@ -420,8 +420,8 @@ impl App {
|
|||
self.stashmsg_popup.show()?
|
||||
}
|
||||
InternalEvent::TabSwitch => self.set_tab(0)?,
|
||||
InternalEvent::InspectCommit(id) => {
|
||||
self.inspect_commit_popup.open(id)?;
|
||||
InternalEvent::InspectCommit(id, tags) => {
|
||||
self.inspect_commit_popup.open(id, tags)?;
|
||||
flags.insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS)
|
||||
}
|
||||
InternalEvent::OpenExternalEditor(path) => {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@ use crate::{
|
|||
};
|
||||
use anyhow::Result;
|
||||
use asyncgit::{
|
||||
sync::{self, CommitDetails, CommitId, Tags},
|
||||
sync::{self, CommitDetails, CommitId},
|
||||
CWD,
|
||||
};
|
||||
use crossterm::event::Event;
|
||||
use std::borrow::Cow;
|
||||
use sync::CommitTags;
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
|
|
@ -40,7 +41,7 @@ impl DetailsComponent {
|
|||
pub fn set_commit(
|
||||
&mut self,
|
||||
id: Option<CommitId>,
|
||||
tags: Option<&Tags>,
|
||||
tags: Option<CommitTags>,
|
||||
) -> Result<()> {
|
||||
self.tags.clear();
|
||||
|
||||
|
|
@ -50,12 +51,8 @@ impl DetailsComponent {
|
|||
None
|
||||
};
|
||||
|
||||
if let Some(id) = id {
|
||||
if let Some(tags) = tags {
|
||||
if let Some(tags) = tags.get(&id) {
|
||||
self.tags.extend(tags.clone());
|
||||
}
|
||||
}
|
||||
if let Some(tags) = tags {
|
||||
self.tags.extend(tags)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
};
|
||||
use anyhow::Result;
|
||||
use asyncgit::{
|
||||
sync::{CommitId, Tags},
|
||||
sync::{CommitId, CommitTags},
|
||||
AsyncCommitFiles, AsyncNotification,
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
|
|
@ -68,7 +68,7 @@ impl CommitDetailsComponent {
|
|||
pub fn set_commit(
|
||||
&mut self,
|
||||
id: Option<CommitId>,
|
||||
tags: Option<&Tags>,
|
||||
tags: Option<CommitTags>,
|
||||
) -> Result<()> {
|
||||
self.details.set_commit(id, tags)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use crate::{
|
|||
};
|
||||
use anyhow::Result;
|
||||
use asyncgit::{
|
||||
sync::CommitId, AsyncDiff, AsyncNotification, DiffParams,
|
||||
DiffType,
|
||||
sync::{CommitId, CommitTags},
|
||||
AsyncDiff, AsyncNotification, DiffParams, DiffType,
|
||||
};
|
||||
use crossbeam_channel::Sender;
|
||||
use crossterm::event::Event;
|
||||
|
|
@ -23,6 +23,7 @@ use tui::{
|
|||
|
||||
pub struct InspectCommitComponent {
|
||||
commit_id: Option<CommitId>,
|
||||
tags: Option<CommitTags>,
|
||||
diff: DiffComponent,
|
||||
details: CommitDetailsComponent,
|
||||
git_diff: AsyncDiff,
|
||||
|
|
@ -160,14 +161,20 @@ impl InspectCommitComponent {
|
|||
),
|
||||
diff: DiffComponent::new(None, theme),
|
||||
commit_id: None,
|
||||
tags: None,
|
||||
git_diff: AsyncDiff::new(sender.clone()),
|
||||
visible: false,
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
pub fn open(&mut self, id: CommitId) -> Result<()> {
|
||||
pub fn open(
|
||||
&mut self,
|
||||
id: CommitId,
|
||||
tags: Option<CommitTags>,
|
||||
) -> Result<()> {
|
||||
self.commit_id = Some(id);
|
||||
self.tags = tags;
|
||||
self.show()?;
|
||||
|
||||
Ok(())
|
||||
|
|
@ -225,7 +232,7 @@ impl InspectCommitComponent {
|
|||
}
|
||||
|
||||
fn update(&mut self) -> Result<()> {
|
||||
self.details.set_commit(self.commit_id, None)?;
|
||||
self.details.set_commit(self.commit_id, self.tags.clone())?;
|
||||
self.update_diff()?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::tabs::StashingOptions;
|
||||
use asyncgit::sync::CommitId;
|
||||
use asyncgit::sync::{CommitId, CommitTags};
|
||||
use bitflags::bitflags;
|
||||
use std::{cell::RefCell, collections::VecDeque, rc::Rc};
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ pub enum InternalEvent {
|
|||
///
|
||||
TabSwitch,
|
||||
///
|
||||
InspectCommit(CommitId),
|
||||
InspectCommit(CommitId, Option<CommitTags>),
|
||||
///
|
||||
OpenExternalEditor(Option<String>),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use asyncgit::{
|
|||
use crossbeam_channel::Sender;
|
||||
use crossterm::event::Event;
|
||||
use std::time::Duration;
|
||||
use sync::CommitTags;
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
|
|
@ -89,10 +90,10 @@ impl Revlog {
|
|||
);
|
||||
|
||||
if self.commit_details.is_visible() {
|
||||
self.commit_details.set_commit(
|
||||
self.selected_commit(),
|
||||
self.list.tags(),
|
||||
)?;
|
||||
let commit = self.selected_commit();
|
||||
let tags = self.selected_commit_tags(&commit);
|
||||
|
||||
self.commit_details.set_commit(commit, tags)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,6 +142,25 @@ impl Revlog {
|
|||
fn selected_commit(&self) -> Option<CommitId> {
|
||||
self.list.selected_entry().map(|e| e.id)
|
||||
}
|
||||
|
||||
fn selected_commit_tags(
|
||||
&self,
|
||||
commit: &Option<CommitId>,
|
||||
) -> Option<CommitTags> {
|
||||
let tags = self.list.tags();
|
||||
|
||||
commit.and_then(|commit| {
|
||||
if let Some(tags) = tags {
|
||||
if let Some(tags) = tags.get(&commit) {
|
||||
Some(tags.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawableComponent for Revlog {
|
||||
|
|
@ -194,7 +214,12 @@ impl Component for Revlog {
|
|||
self.selected_commit()
|
||||
{
|
||||
self.queue.borrow_mut().push_back(
|
||||
InternalEvent::InspectCommit(id),
|
||||
InternalEvent::InspectCommit(
|
||||
id,
|
||||
self.selected_commit_tags(&Some(
|
||||
id,
|
||||
)),
|
||||
),
|
||||
);
|
||||
Ok(true)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ impl StashList {
|
|||
if let Some(e) = self.list.selected_entry() {
|
||||
self.queue
|
||||
.borrow_mut()
|
||||
.push_back(InternalEvent::InspectCommit(e.id));
|
||||
.push_back(InternalEvent::InspectCommit(e.id, None));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue