mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Do not further update 'modified' if it's explicitly set
This commit is contained in:
parent
b963af9b4b
commit
f94df28226
1 changed files with 23 additions and 1 deletions
|
@ -379,9 +379,18 @@ impl<'r> TaskMut<'r> {
|
|||
}
|
||||
|
||||
/// Set a tasks's property by name.
|
||||
///
|
||||
/// This will not automatically update the `modified` timestamp or perform any other
|
||||
/// "automatic" operations -- it simply sets the property. Howerver, if property is
|
||||
/// "modified", then subsequent calls to other `set_..` methods will not update the
|
||||
/// `modified` timestamp.
|
||||
pub fn set_value<S: Into<String>>(&mut self, property: S, value: Option<String>) -> Result<()> {
|
||||
let property = property.into();
|
||||
|
||||
if &property == "modified" {
|
||||
self.updated_modified = true;
|
||||
}
|
||||
|
||||
if let Some(ref v) = value {
|
||||
trace!("task {}: set property {}={:?}", self.task.uuid, property, v);
|
||||
} else {
|
||||
|
@ -531,7 +540,7 @@ impl<'r> TaskMut<'r> {
|
|||
|
||||
fn set_string<S: Into<String>>(&mut self, property: S, value: Option<String>) -> Result<()> {
|
||||
let property = property.into();
|
||||
// updated the modified timestamp unless we are setting it explicitly
|
||||
// update the modified timestamp unless we are setting it explicitly
|
||||
if &property != "modified" {
|
||||
self.update_modified()?;
|
||||
}
|
||||
|
@ -1195,4 +1204,17 @@ mod test {
|
|||
assert!(t2.has_tag(&stag(SyntheticTag::Unblocked)));
|
||||
assert!(t2.has_tag(&stag(SyntheticTag::Blocking)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_value_modiifed() {
|
||||
with_mut_task(|mut task| {
|
||||
// set the modified property to something in the past..
|
||||
task.set_value("modified", Some("1671820000".into()))
|
||||
.unwrap();
|
||||
// update another property
|
||||
task.set_description("fun times".into()).unwrap();
|
||||
// verify the modified property was not updated
|
||||
assert_eq!(task.get_value("modified").unwrap(), "1671820000")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue