diff options
Diffstat (limited to 'src/git_mirror.rs')
| -rw-r--r-- | src/git_mirror.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/git_mirror.rs b/src/git_mirror.rs index 47c0442..6866de3 100644 --- a/src/git_mirror.rs +++ b/src/git_mirror.rs | |||
| @@ -134,7 +134,18 @@ impl GitMirror { | |||
| 134 | let repo = git2::Repository::open(repo_path) | 134 | let repo = git2::Repository::open(repo_path) |
| 135 | .with_context(|| format!("failed to open bare repo at {:?}", repo_path))?; | 135 | .with_context(|| format!("failed to open bare repo at {:?}", repo_path))?; |
| 136 | 136 | ||
| 137 | let mut remote = repo.remote("push_target", target_url)?; | 137 | let remote_name = "push_target"; |
| 138 | |||
| 139 | match repo.find_remote(remote_name) { | ||
| 140 | Ok(_) => { | ||
| 141 | repo.remote_set_url(remote_name, target_url)?; | ||
| 142 | } | ||
| 143 | Err(_) => { | ||
| 144 | repo.remote(remote_name, target_url)?; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | let mut remote = repo.find_remote(remote_name)?; | ||
| 138 | 149 | ||
| 139 | let mut callbacks = RemoteCallbacks::new(); | 150 | let mut callbacks = RemoteCallbacks::new(); |
| 140 | callbacks.credentials(|_url, _username, _allowed| git2::Cred::default()); | 151 | callbacks.credentials(|_url, _username, _allowed| git2::Cred::default()); |