|
27 | 27 | import org.eclipse.jgit.lib.RefUpdate.Result;
|
28 | 28 | import org.eclipse.jgit.lib.Repository;
|
29 | 29 | import org.eclipse.jgit.lib.StoredConfig;
|
| 30 | +import org.eclipse.jgit.transport.CredentialsProvider; |
30 | 31 | import org.eclipse.jgit.transport.FetchResult;
|
31 | 32 | import org.eclipse.jgit.transport.ReceiveCommand;
|
32 | 33 | import org.eclipse.jgit.transport.ReceiveCommand.Type;
|
33 | 34 | import org.eclipse.jgit.transport.RemoteConfig;
|
34 | 35 | import org.eclipse.jgit.transport.TrackingRefUpdate;
|
| 36 | +import org.eclipse.jgit.transport.URIish; |
| 37 | +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; |
35 | 38 | import org.slf4j.Logger;
|
36 | 39 | import org.slf4j.LoggerFactory;
|
37 | 40 |
|
@@ -146,7 +149,12 @@ public void run() {
|
146 | 149 | logger.debug("checking {} remote {} for ref updates", repositoryName, mirror.getName());
|
147 | 150 | final boolean testing = false;
|
148 | 151 | Git git = new Git(repository);
|
149 |
| - FetchResult result = git.fetch().setRemote(mirror.getName()).setDryRun(testing).call(); |
| 152 | + CredentialsProvider creds = null; |
| 153 | + URIish fetchUri = mirror.getURIs().get(0); |
| 154 | + if (fetchUri.getUser() != null && fetchUri.getPass() != null) { |
| 155 | + creds = new UsernamePasswordCredentialsProvider(fetchUri.getUser(), fetchUri.getPass()); |
| 156 | + } |
| 157 | + FetchResult result = git.fetch().setCredentialsProvider(creds).setRemote(mirror.getName()).setDryRun(testing).call(); |
150 | 158 | Collection<TrackingRefUpdate> refUpdates = result.getTrackingRefUpdates();
|
151 | 159 | if (refUpdates.size() > 0) {
|
152 | 160 | ReceiveCommand ticketBranchCmd = null;
|
|
0 commit comments