History

support reflog message prefix (#450)

Sebastian Thiel committed 4 years ago

Commit 6ebbbc11 parent 9a072bd3 files · +10 −6Browse files

Unified · Split

3 files
  1. git-repository/src/remote/connection/fetch/mod.rs +1 −0
  2. git-repository/src/remote/connection/fetch/update_refs/mod.rs +3 −1
  3. git-repository/src/remote/connection/fetch/update_refs/tests.rs +6 −5
git-repository/src/remote/connection/fetch/mod.rs+1−0
@@ -177,6 +177,7 @@ where · 176 unmodified lines
177 177
178 let update_refs = refs::update(178 let update_refs = refs::update(
179 repo,179 repo,
180 "fetch",
180 &self.ref_map.mappings,181 &self.ref_map.mappings,
181 con.remote.refspecs(crate::remote::Direction::Fetch),182 con.remote.refspecs(crate::remote::Direction::Fetch),
182 fetch::DryRun::No,183 fetch::DryRun::No,
git-repository/src/remote/connection/fetch/update_refs/mod.rs+3−1
@@ -30,10 +30,12 @@ impl From<update::Mode> for Update { · 29 unmodified lines
30/// [`update`][Update] corresponding to the [`fetch::Mapping`] of at the same index.30/// [`update`][Update] corresponding to the [`fetch::Mapping`] of at the same index.
31/// If `dry_run` is true, ref transactions won't actually be applied, but are assumed to work without error so the underlying31/// If `dry_run` is true, ref transactions won't actually be applied, but are assumed to work without error so the underlying
32/// `repo` is not actually changed.32/// `repo` is not actually changed.
33/// `action` is the prefix used for reflog entries, and is typically "fetch".
33///34///
34/// It can be used to produce typical information that one is used to from `git fetch`.35/// It can be used to produce typical information that one is used to from `git fetch`.
35pub(crate) fn update(36pub(crate) fn update(
36 repo: &Repository,37 repo: &Repository,
38 action: &str,
37 mappings: &[fetch::Mapping],39 mappings: &[fetch::Mapping],
38 refspecs: &[git_refspec::RefSpec],40 refspecs: &[git_refspec::RefSpec],
39 dry_run: fetch::DryRun,41 dry_run: fetch::DryRun,
@@ -91,7 +93,7 @@ pub(crate) fn update( · 51 unmodified lines
91 log: LogChange {93 log: LogChange {
92 mode: RefLog::AndReference,94 mode: RefLog::AndReference,
93 force_create_reflog: false,95 force_create_reflog: false,
94 message: reflog_message.into(),96 message: format!("{}: {}", action, reflog_message).into(),
95 },97 },
96 expected: PreviousValue::ExistingMustMatch(Target::Peeled(remote_id.into())),98 expected: PreviousValue::ExistingMustMatch(Target::Peeled(remote_id.into())),
97 new: Target::Peeled(remote_id.into()),99 new: Target::Peeled(remote_id.into()),
git-repository/src/remote/connection/fetch/update_refs/tests.rs+6−5
@@ -93,7 +93,7 @@ mod update { · 92 unmodified lines
93 // ),93 // ),
94 ] {94 ] {
95 let (mapping, specs) = mapping_from_spec(spec, &repo);95 let (mapping, specs) = mapping_from_spec(spec, &repo);
96 let out = fetch::refs::update(&repo, &mapping, &specs, fetch::DryRun::Yes).unwrap();96 let out = fetch::refs::update(&repo, "action", &mapping, &specs, fetch::DryRun::Yes).unwrap();
97 97
98 assert_eq!(98 assert_eq!(
99 out.updates,99 out.updates,
@@ -109,7 +109,8 @@ mod update { · 9 unmodified lines
109 match &edit.change {109 match &edit.change {
110 Change::Update { log, .. } => {110 Change::Update { log, .. } => {
111 assert_eq!(111 assert_eq!(
112 log.message, reflog_message,112 log.message,
113 format!("action: {}", reflog_message),
113 "reflog messages are specific and we emulate git word for word"114 "reflog messages are specific and we emulate git word for word"
114 );115 );
115 }116 }
@@ -137,7 +138,7 @@ mod update { · 21 unmodified lines
137 ] {138 ] {
138 let spec = format!("refs/heads/main:refs/heads/{}", branch);139 let spec = format!("refs/heads/main:refs/heads/{}", branch);
139 let (mappings, specs) = mapping_from_spec(&spec, &repo);140 let (mappings, specs) = mapping_from_spec(&spec, &repo);
140 let out = fetch::refs::update(&repo, &mappings, &specs, fetch::DryRun::Yes)?;141 let out = fetch::refs::update(&repo, "action", &mappings, &specs, fetch::DryRun::Yes)?;
141 142
142 assert_eq!(143 assert_eq!(
143 out.updates,144 out.updates,
@@ -158,7 +159,7 @@ mod update { · 14 unmodified lines
158 fn symbolic_refs_are_never_written() {159 fn symbolic_refs_are_never_written() {
159 let repo = repo("two-origins");160 let repo = repo("two-origins");
160 let (mappings, specs) = mapping_from_spec("refs/heads/main:refs/heads/symbolic", &repo);161 let (mappings, specs) = mapping_from_spec("refs/heads/main:refs/heads/symbolic", &repo);
161 let out = fetch::refs::update(&repo, &mappings, &specs, fetch::DryRun::Yes).unwrap();162 let out = fetch::refs::update(&repo, "action", &mappings, &specs, fetch::DryRun::Yes).unwrap();
162 163
163 assert_eq!(164 assert_eq!(
164 out.updates,165 out.updates,
@@ -176,7 +177,7 @@ mod update { · 11 unmodified lines
176 fn fast_forward_is_not_implemented_yet_but_should_be_denied() {177 fn fast_forward_is_not_implemented_yet_but_should_be_denied() {
177 let repo = repo("two-origins");178 let repo = repo("two-origins");
178 let (mappings, specs) = mapping_from_spec("refs/heads/main:refs/remotes/origin/g", &repo);179 let (mappings, specs) = mapping_from_spec("refs/heads/main:refs/remotes/origin/g", &repo);
179 let out = fetch::refs::update(&repo, &mappings, &specs, fetch::DryRun::Yes).unwrap();180 let out = fetch::refs::update(&repo, "action", &mappings, &specs, fetch::DryRun::Yes).unwrap();
180 181
181 assert_eq!(182 assert_eq!(
182 out.updates,183 out.updates,