Skip to content

Commit df413b5

Browse files
author
Stephan Dilly
committed
Merge branch 'master' of github.com:Extrawurst/gitui
2 parents 86c7e64 + 8b096fb commit df413b5

File tree

5 files changed

+62
-11
lines changed

5 files changed

+62
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- name: Run clippy
2727
run: |
2828
rustup component add clippy
29+
cargo clean
2930
make clippy
3031
- name: Build Release
3132
run: make build-release

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- better error message when trying to run outside of a valid git repo ([#56](https://github.com/extrawurst/gitui/issues/56))
1818
- improve ctrl+c handling so it is checked first and no component needs to worry of blocking it
1919

20+
### Fixed
21+
- support multiple tags per commit in log ([#61](https://github.com/extrawurst/gitui/issues/61))
22+
2023
## [0.2.3] - 2020-05-12
2124
### Added
2225
- support more navigation keys: home/end/pageUp/pageDown ([#43](https://github.com/extrawurst/gitui/issues/43))

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test:
2626
cargo test --workspace
2727

2828
clippy:
29-
cargo clean
29+
cargo clean -p gitui -p asyncgit -p scopetime
3030
cargo clippy --all-features
3131

3232
clippy-pedantic:

asyncgit/src/sync/tags.rs

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ use crate::error::Result;
33
use scopetime::scope_time;
44
use std::collections::HashMap;
55

6-
/// hashmap of tag target commit hash to tag name
7-
pub type Tags = HashMap<String, String>;
6+
/// hashmap of tag target commit hash to tag names
7+
pub type Tags = HashMap<String, Vec<String>>;
88

99
/// returns `Tags` type filled with all tags found in repo
1010
pub fn get_tags(repo_path: &str) -> Result<Tags> {
1111
scope_time!("get_tags");
1212

1313
let mut res = Tags::new();
14+
let mut adder = |key: String, value: String| {
15+
if let Some(key) = res.get_mut(&key) {
16+
key.push(value)
17+
} else {
18+
res.insert(key, vec![value]);
19+
}
20+
};
1421

1522
let repo = repo(repo_path)?;
1623

@@ -21,10 +28,50 @@ pub fn get_tags(repo_path: &str) -> Result<Tags> {
2128
if let Some(tag) = obj.as_tag() {
2229
let target_hash = tag.target_id().to_string();
2330
let tag_name = String::from(name);
24-
res.insert(target_hash, tag_name);
31+
adder(target_hash, tag_name);
2532
}
2633
}
2734
}
2835

2936
Ok(res)
3037
}
38+
39+
#[cfg(test)]
40+
mod tests {
41+
use super::*;
42+
use crate::sync::tests::repo_init;
43+
use git2::ObjectType;
44+
45+
#[test]
46+
fn test_smoke() {
47+
let (_td, repo) = repo_init().unwrap();
48+
let root = repo.path().parent().unwrap();
49+
let repo_path = root.as_os_str().to_str().unwrap();
50+
51+
assert_eq!(get_tags(repo_path).unwrap().is_empty(), true);
52+
}
53+
54+
#[test]
55+
fn test_multitags() {
56+
let (_td, repo) = repo_init().unwrap();
57+
let root = repo.path().parent().unwrap();
58+
let repo_path = root.as_os_str().to_str().unwrap();
59+
60+
let sig = repo.signature().unwrap();
61+
let head_id = repo.head().unwrap().target().unwrap();
62+
let target = repo
63+
.find_object(
64+
repo.head().unwrap().target().unwrap(),
65+
Some(ObjectType::Commit),
66+
)
67+
.unwrap();
68+
69+
repo.tag("a", &target, &sig, "", false).unwrap();
70+
repo.tag("b", &target, &sig, "", false).unwrap();
71+
72+
assert_eq!(
73+
get_tags(repo_path).unwrap()[&head_id.to_string()],
74+
vec!["a", "b"]
75+
);
76+
}
77+
}

src/tabs/revlog/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl Revlog {
167167
e: &'a LogEntry,
168168
selected: bool,
169169
txt: &mut Vec<Text<'a>>,
170-
tag: &'a str,
170+
tags: Option<String>,
171171
) {
172172
let count_before = txt.len();
173173

@@ -209,10 +209,10 @@ impl Revlog {
209209
));
210210
txt.push(splitter.clone());
211211
txt.push(Text::Styled(
212-
Cow::from(if tag.is_empty() {
213-
String::from("")
212+
Cow::from(if let Some(tags) = tags {
213+
format!(" {}", tags)
214214
} else {
215-
format!(" {}", tag)
215+
String::from("")
216216
}),
217217
if selected {
218218
STYLE_TAG_SELECTED
@@ -250,10 +250,10 @@ impl DrawableComponent for Revlog {
250250

251251
let mut txt = Vec::new();
252252
for (idx, e) in self.items.items.iter().enumerate() {
253-
let tag = if let Some(tag_name) = self.tags.get(&e.hash) {
254-
tag_name.as_str()
253+
let tag = if let Some(tags) = self.tags.get(&e.hash) {
254+
Some(tags.join(" "))
255255
} else {
256-
""
256+
None
257257
};
258258
Self::add_entry(e, idx == selection, &mut txt, tag);
259259
}

0 commit comments

Comments
 (0)