Commit 75a5f28d authored by Ben Boeckel's avatar Ben Boeckel

run: use a &Identity rather than owning one

parent d5b8b7e1
Pipeline #24444 passed with stage
......@@ -28,12 +28,12 @@ pub enum AttributeState {
/// Git context for use in hooks.
pub struct HookGitContext<'a> {
workarea: PreparedGitWorkArea<'a>,
topic_owner: Identity,
topic_owner: &'a Identity,
}
impl<'a> HookGitContext<'a> {
/// Create a new hook git context.
pub fn new(workarea: PreparedGitWorkArea<'a>, topic_owner: Identity) -> Self {
pub fn new(workarea: PreparedGitWorkArea<'a>, topic_owner: &'a Identity) -> Self {
HookGitContext {
workarea: workarea,
topic_owner: topic_owner,
......@@ -106,7 +106,7 @@ mod tests {
let prep_ctx = ctx.prepare(None, sha1, &submodules).unwrap();
let ben = Identity::new("Ben Boeckel", "ben.boeckel@kitware.com");
let hook_ctx = HookGitContext::new(prep_ctx, ben);
let hook_ctx = HookGitContext::new(prep_ctx, &ben);
assert_eq!(hook_ctx.check_attr("foo", "file1").unwrap(),
AttributeState::Value("bar".to_owned()));
......
......@@ -35,6 +35,6 @@ pub fn test_hook<'a>(test_name: &str, topic: &str, conf: &GitHookConfiguration<'
run_hooks(&ctx,
conf,
&refs,
Identity::new("Rust Kitware Hook Tests", "rust-kitware-hooks@example.com"))
&Identity::new("Rust Kitware Hook Tests", "rust-kitware-hooks@example.com"))
.unwrap()
}
......@@ -74,7 +74,7 @@ pub fn list_refs(ctx: &GitContext, reason: &str, base_branch: &str, topic: &str)
/// Run hooks over all refs and collect results from the hooks.
pub fn run_hooks<'a, S>(ctx: &GitContext, conf: &GitHookConfiguration<'a>, refs: &[S],
topic_owner: Identity)
topic_owner: &Identity)
-> Result<HookResult, Error>
where S: AsRef<str>,
{
......@@ -82,7 +82,7 @@ pub fn run_hooks<'a, S>(ctx: &GitContext, conf: &GitHookConfiguration<'a>, refs:
for sha1 in refs.iter() {
let workarea = try!(ctx.prepare(conf.config, sha1.as_ref(), conf.submodules));
let hook_ctx = HookGitContext::new(workarea, topic_owner.clone());
let hook_ctx = HookGitContext::new(workarea, topic_owner);
let commit = try!(Commit::new(ctx, sha1.as_ref()));
......@@ -101,7 +101,7 @@ pub fn run_hooks<'a, S>(ctx: &GitContext, conf: &GitHookConfiguration<'a>, refs:
if !refs.is_empty() {
let workarea = try!(ctx.prepare(conf.config, refs[0].as_ref(), conf.submodules));
let hook_ctx = HookGitContext::new(workarea, topic_owner.clone());
let hook_ctx = HookGitContext::new(workarea, topic_owner);
for hook in conf.hooks_branch.iter() {
debug!(target: "hooks", "running hook {}", hook.name());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment