use of org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider in project egit by eclipse.
the class PushTest method setup.
@Before
public void setup() throws Exception {
TestUtil.disableProxy();
remoteRepository = new SampleTestRepository(NUMBER_RANDOM_COMMITS, true);
localRepoPath = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), "test" + System.nanoTime());
String branch = Constants.R_HEADS + SampleTestRepository.FIX;
CloneOperation cloneOperation = new CloneOperation(new URIish(remoteRepository.getUri()), true, null, localRepoPath, branch, "origin", 30);
cloneOperation.setCredentialsProvider(new UsernamePasswordCredentialsProvider("agitter", "letmein"));
cloneOperation.run(new NullProgressMonitor());
file = new File(localRepoPath, SampleTestRepository.A_txt_name);
assertTrue(file.exists());
localRepository = Activator.getDefault().getRepositoryCache().lookupRepository(new File(localRepoPath, ".git"));
assertNotNull(localRepository);
}
use of org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider in project ArTEMiS by ls1intum.
the class GitService method pull.
/**
* Pulls from remote repository.
*
* @param repo Local Repository Object.
* @return The PullResult which contains FetchResult and MergeResult.
* @throws GitAPIException
*/
public PullResult pull(Repository repo) throws GitAPIException {
Git git = new Git(repo);
// flush cache of files
repo.setFiles(null);
return git.pull().setCredentialsProvider(new UsernamePasswordCredentialsProvider(GIT_USER, GIT_PASSWORD)).call();
}
use of org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider in project zeppelin by apache.
the class GitHubNotebookRepo method pushToRemoteSteam.
private void pushToRemoteSteam() {
try {
LOG.debug("Pushing latest changes to remote stream");
PushCommand pushCommand = git.push();
pushCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(zeppelinConfiguration.getZeppelinNotebookGitUsername(), zeppelinConfiguration.getZeppelinNotebookGitAccessToken()));
pushCommand.call();
} catch (GitAPIException e) {
LOG.error("Error when pushing latest changes to remote repository", e);
}
}
use of org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider in project zeppelin by apache.
the class GitHubNotebookRepo method pullFromRemoteStream.
private void pullFromRemoteStream() {
try {
LOG.debug("Pulling latest changes from remote stream");
PullCommand pullCommand = git.pull();
pullCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(zeppelinConfiguration.getZeppelinNotebookGitUsername(), zeppelinConfiguration.getZeppelinNotebookGitAccessToken()));
pullCommand.call();
} catch (GitAPIException e) {
LOG.error("Error when pulling latest changes from remote repository", e);
}
}
use of org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider in project zaproxy by zaproxy.
the class CreateTagAndGitHubRelease method createTag.
private void createTag() throws Exception {
Repository repository = new FileRepositoryBuilder().setGitDir(new File(getProject().getRootDir(), ".git")).build();
try (Git git = new Git(repository)) {
URIish originUri = new URIish(GITHUB_BASE_URL + getRepo().get());
git.remoteSetUrl().setRemoteName(GIT_REMOTE_ORIGIN).setRemoteUri(originUri).call();
GitHubUser ghUser = getUser().get();
PersonIdent personIdent = new PersonIdent(ghUser.getName(), ghUser.getEmail());
Ref tag = git.tag().setName(getTag().get()).setMessage(getTagMessage().get()).setAnnotated(true).setTagger(personIdent).call();
git.push().setCredentialsProvider(new UsernamePasswordCredentialsProvider(ghUser.getName(), ghUser.getAuthToken())).add(tag).call();
}
}
Aggregations