Skip to content

Commit

Permalink
refactor: replace linked-hash-map with indexmap
Browse files Browse the repository at this point in the history
  • Loading branch information
its-danny committed May 1, 2022
1 parent 8d19772 commit 0b4d689
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
12 changes: 3 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ conventional_commit_parser = "0.9.4"
dirs = "4.0.0"
emojis = "0.4.0"
git2 = "0.14.3"
linked-hash-map = "0.5.4"
openssl-sys = { version = "0.9.72", features = [ "vendored" ] }
indexmap = "1.8.1"
openssl-sys = { version = "0.9.72", features = ["vendored"] }
requestty = "0.3.0"
serde = { version = "1.0.136", features = [ "derive" ] }
serde = { version = "1.0.136", features = ["derive"] }
toml = "0.5.9"

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions src/lib/answers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{Context, Result};
use linked_hash_map::LinkedHashMap;
use indexmap::IndexMap;
use requestty::{Answer, Answers};

use crate::{
Expand Down Expand Up @@ -44,7 +44,7 @@ fn get_summary(
answer: Option<&Answer>,
use_emoji: bool,
commit_type: &str,
commit_types: &LinkedHashMap<String, CommitType>,
commit_types: &IndexMap<String, CommitType>,
) -> Result<String> {
answer
.context("could not get summary")?
Expand Down Expand Up @@ -137,7 +137,7 @@ pub struct ExtractedAnswers {
pub fn get_extracted_answers(
answers: &Answers,
use_emoji: bool,
commit_types: &LinkedHashMap<String, CommitType>,
commit_types: &IndexMap<String, CommitType>,
) -> Result<ExtractedAnswers> {
let commit_type = get_commit_type(answers.get(Q_COMMIT_TYPE))?.to_string();
let scope = get_scope(answers.get(Q_SCOPE))?;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/commit_types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use linked_hash_map::LinkedHashMap;
use indexmap::IndexMap;
use serde::Deserialize;

use crate::config::Config;
Expand All @@ -11,8 +11,8 @@ pub struct CommitType {
}

/// Get commit types from config.
pub fn get_commit_types(config: &Config) -> LinkedHashMap<String, CommitType> {
let mut map = LinkedHashMap::new();
pub fn get_commit_types(config: &Config) -> IndexMap<String, CommitType> {
let mut map = IndexMap::new();

for commit_type in config.commit_types.iter() {
map.insert(commit_type.name.to_owned(), commit_type.to_owned());
Expand Down
6 changes: 3 additions & 3 deletions src/lib/questions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{Context, Result};
use conventional_commit_parser::parse_summary;
use git2::Repository;
use linked_hash_map::LinkedHashMap;
use indexmap::IndexMap;
use requestty::{
prompt,
question::{completions, Completions},
Expand Down Expand Up @@ -56,7 +56,7 @@ fn transform_commit_type_choice(choice: &str) -> String {
fn format_commit_type_choice(
use_emoji: bool,
commit_type: &CommitType,
commit_types: &LinkedHashMap<String, CommitType>,
commit_types: &IndexMap<String, CommitType>,
) -> String {
let name = &commit_type.name;
let description = &commit_type.description;
Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn create_prompt(
message: String,
use_emoji: bool,
use_autocomplete: bool,
commit_types: &LinkedHashMap<String, CommitType>,
commit_types: &IndexMap<String, CommitType>,
) -> Result<Answers> {
// Scan history for existing scopes we can use
// to autocomplete the scope prompt.
Expand Down

0 comments on commit 0b4d689

Please sign in to comment.