Compare commits
No commits in common. "def729d43a761d07a1a3851cdb87ca663a167a2a" and "cfe49adca90c60bd669b963875f91f76e4ebd6f4" have entirely different histories.
def729d43a
...
cfe49adca9
2 changed files with 97 additions and 138 deletions
|
|
@ -415,25 +415,7 @@ fn handle_command(
|
|||
Commands::Assign {
|
||||
issue_id,
|
||||
new_assignee,
|
||||
} => match new_assignee {
|
||||
Some(new_assignee) => {
|
||||
let issues_database = entomologist::database::make_issues_database(
|
||||
issues_database_source,
|
||||
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||
)?;
|
||||
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||
let Some(issue) = issues.get_mut_issue(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
let old_assignee: String = match &issue.assignee {
|
||||
Some(assignee) => assignee.clone(),
|
||||
None => String::from("None"),
|
||||
};
|
||||
issue.set_assignee(new_assignee)?;
|
||||
println!("issue: {}", issue_id);
|
||||
println!("assignee: {} -> {}", old_assignee, new_assignee);
|
||||
}
|
||||
None => {
|
||||
} => {
|
||||
let issues = entomologist::database::read_issues_database(issues_database_source)?;
|
||||
let Some(original_issue) = issues.issues.get(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
|
|
@ -443,24 +425,46 @@ fn handle_command(
|
|||
None => String::from("None"),
|
||||
};
|
||||
println!("issue: {}", issue_id);
|
||||
println!("assignee: {}", old_assignee);
|
||||
}
|
||||
},
|
||||
|
||||
Commands::Tag { issue_id, tag } => match tag {
|
||||
Some(tag) => {
|
||||
// Add or remove tag.
|
||||
if tag.len() == 0 {
|
||||
return Err(anyhow::anyhow!("invalid zero-length tag"));
|
||||
}
|
||||
match new_assignee {
|
||||
Some(new_assignee) => {
|
||||
let issues_database = entomologist::database::make_issues_database(
|
||||
issues_database_source,
|
||||
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||
)?;
|
||||
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||
let mut issues =
|
||||
entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||
let Some(issue) = issues.get_mut_issue(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
println!("assignee: {} -> {}", old_assignee, new_assignee);
|
||||
issue.set_assignee(new_assignee)?;
|
||||
}
|
||||
None => {
|
||||
println!("assignee: {}", old_assignee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Commands::Tag { issue_id, tag } => {
|
||||
let issues = entomologist::database::read_issues_database(issues_database_source)?;
|
||||
let Some(issue) = issues.issues.get(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
match tag {
|
||||
Some(tag) => {
|
||||
// Add or remove tag.
|
||||
let issues_database = entomologist::database::make_issues_database(
|
||||
issues_database_source,
|
||||
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||
)?;
|
||||
let mut issues =
|
||||
entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||
let Some(issue) = issues.get_mut_issue(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
if tag.len() == 0 {
|
||||
return Err(anyhow::anyhow!("invalid zero-length tag"));
|
||||
}
|
||||
if tag.chars().nth(0).unwrap() == '-' {
|
||||
let tag = &tag[1..];
|
||||
issue.remove_tag(tag)?;
|
||||
|
|
@ -470,10 +474,6 @@ fn handle_command(
|
|||
}
|
||||
None => {
|
||||
// Just list the tags.
|
||||
let issues = entomologist::database::read_issues_database(issues_database_source)?;
|
||||
let Some(issue) = issues.issues.get(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
match &issue.tags.len() {
|
||||
0 => println!("no tags"),
|
||||
_ => {
|
||||
|
|
@ -487,19 +487,26 @@ fn handle_command(
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Commands::DoneTime {
|
||||
issue_id,
|
||||
done_time,
|
||||
} => match done_time {
|
||||
} => {
|
||||
let issues = entomologist::database::read_issues_database(issues_database_source)?;
|
||||
let Some(issue) = issues.issues.get(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
match done_time {
|
||||
Some(done_time) => {
|
||||
// Add or remove tag.
|
||||
let issues_database = entomologist::database::make_issues_database(
|
||||
issues_database_source,
|
||||
entomologist::database::IssuesDatabaseAccess::ReadWrite,
|
||||
)?;
|
||||
let mut issues = entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||
let mut issues =
|
||||
entomologist::issues::Issues::new_from_dir(&issues_database.dir)?;
|
||||
let Some(issue) = issues.get_mut_issue(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
|
|
@ -512,17 +519,12 @@ fn handle_command(
|
|||
};
|
||||
issue.set_done_time(done_time)?;
|
||||
}
|
||||
None => {
|
||||
let issues = entomologist::database::read_issues_database(issues_database_source)?;
|
||||
let Some(issue) = issues.issues.get(issue_id) else {
|
||||
return Err(anyhow::anyhow!("issue {} not found", issue_id));
|
||||
};
|
||||
match &issue.done_time {
|
||||
None => match &issue.done_time {
|
||||
Some(done_time) => println!("done_time: {}", done_time),
|
||||
None => println!("None"),
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
Commands::Depend {
|
||||
issue_id,
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# * Create a temporary ent issue database branch based on a specific
|
||||
# commit in `entomologist-data`.
|
||||
#
|
||||
# * Perform some ent operations on this temporary branch and measure
|
||||
# the runtime.
|
||||
#
|
||||
# * Clean up by deleteting the temporary branch.
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
|
||||
# This is a commit in the `entomologist-data` branch that we're somewhat
|
||||
# arbitrarily using here to time different `ent` operations.
|
||||
TEST_COMMIT=a33f1165d77571d770f1a1021afe4c07360247f0
|
||||
|
||||
# This is the branch that we create from the above commit and test our
|
||||
# `ent` operations on. We'll delete this branch when we're done with
|
||||
# the tests.
|
||||
TEST_BRANCH=$(mktemp --dry-run entomologist-data-XXXXXXXX)
|
||||
|
||||
|
||||
function time_ent() {
|
||||
echo timing: ent "$@"
|
||||
time -p ent -b "${TEST_BRANCH}" "$@"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
git branch "${TEST_BRANCH}" "${TEST_COMMIT}"
|
||||
|
||||
time_ent tag 7e2a3a59fb6b77403ff1035255367607
|
||||
time_ent tag 7e2a3a59fb6b77403ff1035255367607 new-tag
|
||||
|
||||
time_ent assign 7e2a3a59fb6b77403ff1035255367607
|
||||
time_ent assign 7e2a3a59fb6b77403ff1035255367607 new-user
|
||||
|
||||
time_ent done-time 7e2a3a59fb6b77403ff1035255367607
|
||||
time_ent done-time 7e2a3a59fb6b77403ff1035255367607 2025-04-01T01:23:45-06:00
|
||||
|
||||
git branch -D "${TEST_BRANCH}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue