History

Off-changelog rename `note::Platform::add_to_ref()` to `::replace_at_ref()`

It feels like the better name.

Byron committed 2 months ago

Commit 2c8ddd41 parent 480fb0a8 files · +16 −16Browse files

Unified · Split

8 files
  1. gix-tix/src/command/enrich.rs +1 −1
  2. gix-tix/src/edit/rebase.rs +1 −1
  3. gix-tix/src/edit/split.rs +1 −1
  4. gix-tix/src/edit/todo.rs +2 −2
  5. gix-tix/src/enrich.rs +7 −7
  6. gix-tix/src/lib.rs +1 −1
  7. gix/src/note.rs +2 −2
  8. gix/tests/gix/repository/note.rs +1 −1
gix-tix/src/command/enrich.rs+1−1
@@ -192,7 +192,7 @@ fn edit_git_note(repository: &gix::Repository, args: &Target) -> Result<()> { · 191 unmodified lines
192192 let data: Option<&[u8]> = saved.then_some(cleaned.as_ref());
193193 match data {
194194 Some(data) => notes
195− .add_to_ref(reference.as_ref(), target, data)
195+ .replace_at_ref(reference.as_ref(), target, data)
196196 .context("could not save Git note")?,
197197 None => notes
198198 .remove(reference.as_ref().as_partial_name().to_owned(), target)
gix-tix/src/edit/rebase.rs+1−1
@@ -3219,7 +3219,7 @@ mod tests { · 3218 unmodified lines
32193219 .default_ref()
32203220 .expect("the test repository has a default notes ref")
32213221 .to_owned();
3222− notes.add_to_ref(reference.as_ref(), id, data)?;
3222+ notes.replace_at_ref(reference.as_ref(), id, data)?;
32233223 Ok(())
32243224 }
32253225
gix-tix/src/edit/split.rs+1−1
@@ -193,7 +193,7 @@ mod tests { · 192 unmodified lines
193193 .default_ref()
194194 .expect("the test repository has a default notes ref")
195195 .to_owned();
196− notes.add_to_ref(notes_ref.as_ref(), old, b"source Git note")?;
196+ notes.replace_at_ref(notes_ref.as_ref(), old, b"source Git note")?;
197197 let upper = apply(open(fixture.path())?, &graph, prepared, &edited)?;
198198 let repository = open(fixture.path())?;
199199 assert_eq!(
gix-tix/src/edit/todo.rs+2−2
@@ -1412,10 +1412,10 @@ mod tests { · 1411 unmodified lines
14121412 let change_id = crate::change_id::for_commit(&repo, middle)?;
14131413 let reference: gix::refs::FullName = crate::enrich::REF_NAME.try_into()?;
14141414 repo.notes()?
1415− .add_to_ref(reference.as_ref(), ObjectId::from(change_id), b"[commit")?;
1415+ .replace_at_ref(reference.as_ref(), ObjectId::from(change_id), b"[commit")?;
14161416 let tree_id = crate::enrich::tree_id(&repo, middle)?;
14171417 let reference: gix::refs::FullName = crate::enrich::TREE_REF_NAME.try_into()?;
1418− repo.notes()?.add_to_ref(reference.as_ref(), tree_id, b"[tree")?;
1418+ repo.notes()?.replace_at_ref(reference.as_ref(), tree_id, b"[tree")?;
14191419
14201420 let prepared = prepare_test(&repo, base, base, &commits, Some(tip))?;
14211421 let document = String::from_utf8(prepared.document)?;
gix-tix/src/enrich.rs+7−7
@@ -182,7 +182,7 @@ pub(crate) fn apply_headers( · 181 unmodified lines
182182 };
183183 let reference: FullName = REF_NAME.try_into().expect("the tix enrich reference is valid");
184184 open(repo)?
185− .add_to_ref(reference.as_ref(), object, data)
185+ .replace_at_ref(reference.as_ref(), object, data)
186186 .context("could not write the tix enrichment")?;
187187 Ok(Some(desired))
188188 }
@@ -253,7 +253,7 @@ fn update( · 64 unmodified lines
253253 edit(&mut config)?;
254254 let reference: FullName = REF_NAME.try_into().expect("the tix enrich reference is valid");
255255 notes
256− .add_to_ref(reference.as_ref(), ObjectId::from(change_id), config.to_bstring())
256+ .replace_at_ref(reference.as_ref(), ObjectId::from(change_id), config.to_bstring())
257257 .context("could not write the tix enrichment")?;
258258 load(&mut notes, change_id)
259259 }
@@ -270,7 +270,7 @@ fn update_tree( · 10 unmodified lines
270270 .try_into()
271271 .expect("the tix tree enrich reference is valid");
272272 notes
273− .add_to_ref(reference.as_ref(), tree_id, config.to_bstring())
273+ .replace_at_ref(reference.as_ref(), tree_id, config.to_bstring())
274274 .context("could not write the tix tree enrichment")?;
275275 load_tree(&mut notes, tree_id)
276276 }
@@ -291,7 +291,7 @@ mod tests { · 14 unmodified lines
291291 let id = repo.head_id()?.detach();
292292 let change_id = crate::change_id::for_commit(&repo, id)?;
293293 let reference: FullName = REF_NAME.try_into()?;
294− repo.notes()?.add_to_ref(
294+ repo.notes()?.replace_at_ref(
295295 reference.as_ref(),
296296 ObjectId::from(change_id),
297297 b"[commit]\n\ttodo = true\n\towner = me\n",
@@ -345,7 +345,7 @@ mod tests { · 47 unmodified lines
345345 let original = repo.head_id()?.detach();
346346 let tree = tree_id(&repo, original)?;
347347 let reference: FullName = TREE_REF_NAME.try_into()?;
348− repo.notes()?.add_to_ref(
348+ repo.notes()?.replace_at_ref(
349349 reference.as_ref(),
350350 tree,
351351 b"[tree]\n\tchecks-pass = false\n\towner = me\n",
@@ -457,7 +457,7 @@ mod tests { · 105 unmodified lines
457457 let change_id = crate::change_id::for_commit(&repo, id)?;
458458 let reference: FullName = REF_NAME.try_into()?;
459459 repo.notes()?
460− .add_to_ref(reference.as_ref(), ObjectId::from(change_id), b"[commit")?;
460+ .replace_at_ref(reference.as_ref(), ObjectId::from(change_id), b"[commit")?;
461461
462462 assert!(
463463 load(&mut open(&repo)?, change_id).is_err(),
@@ -469,7 +469,7 @@ mod tests { · 5 unmodified lines
469469 );
470470 let tree = tree_id(&repo, id)?;
471471 let reference: FullName = TREE_REF_NAME.try_into()?;
472− repo.notes()?.add_to_ref(reference.as_ref(), tree, b"[tree")?;
472+ repo.notes()?.replace_at_ref(reference.as_ref(), tree, b"[tree")?;
473473 assert!(
474474 toggle_checks_pass(&repo, id).is_err(),
475475 "tree mutation does not replace malformed enrichments"
gix-tix/src/lib.rs+1−1
@@ -5425,7 +5425,7 @@ fn set_git_note_reporting( · 5424 unmodified lines
54255425 match data {
54265426 Some(data) => {
54275427 notes
5428− .add_to_ref(reference, id, data)
5428+ .replace_at_ref(reference, id, data)
54295429 .context("could not save Git note")?;
54305430 }
54315431 None => {
gix/src/note.rs+2−2
@@ -170,14 +170,14 @@ impl<'repo> Platform<'repo> { · 169 unmodified lines
170170 .try_into()
171171 .or_raise(|| message("The notes reference name is invalid"))?;
172172 let notes_ref = expand_notes_ref(notes_ref.as_ref())?;
173− self.add_to_ref(notes_ref.as_ref(), object, data)
173+ self.replace_at_ref(notes_ref.as_ref(), object, data)
174174 }
175175
176176 /// Replace a note for `object` with `data` in the fully qualified `notes_ref`,
177177 /// or add it if absent, returning the previous note id.
178178 ///
179179 /// Unlike [`Self::replace()`], this does not apply `refs/notes/` shorthand expansion.
180− pub fn add_to_ref(
180+ pub fn replace_at_ref(
181181 &mut self,
182182 notes_ref: &gix_ref::FullNameRef,
183183 object: impl Into<gix_hash::ObjectId>,
gix/tests/gix/repository/note.rs+1−1
@@ -339,7 +339,7 @@ fn add_to_an_exact_fully_qualified_reference() -> crate::Result { · 338 unmodified lines
339339 let mut notes = repo.notes()?;
340340
341341 assert_eq!(
342− notes.add_to_ref(reference.as_ref(), target, b"[commit]\n\ttodo = true\n")?,
342+ notes.replace_at_ref(reference.as_ref(), target, b"[commit]\n\ttodo = true\n")?,
343343 None
344344 );
345345 let mut exact = repo.notes()?.with_refs([reference.as_bstr()])?;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t