| | |
| | |
|
| | | static File jgit2Folder = new File(GitBlitSuite.REPOSITORIES, "working/jgit2");
|
| | |
|
| | | String url = GitBlitSuite.url;
|
| | | String url = GitBlitSuite.gitServletUrl;
|
| | | String account = GitBlitSuite.account;
|
| | | String password = GitBlitSuite.password;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(ticgitFolder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | boolean cloned = false;
|
| | | try {
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(ticgit2Folder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | boolean cloned = false;
|
| | | try {
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(ticgit2Folder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | // try clone again
|
| | | cloned = false;
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(ticgit2Folder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
|
| | | }
|
| | |
|
| | | RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
|
| | | model.accessRestriction = AccessRestrictionType.NONE;
|
| | | GitBlit.self().updateRepositoryModel(model.name, model, false);
|
| | |
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(ticgitFolder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | w.close();
|
| | | git.add().addFilepattern(file.getName()).call();
|
| | | git.commit().setMessage("test commit").call();
|
| | | git.push().setPushAll().call();
|
| | | Iterable<PushResult> results = git.push().setPushAll().call();
|
| | | GitBlitSuite.close(git);
|
| | | for (PushResult result : results) {
|
| | | for (RemoteRefUpdate update : result.getRemoteUpdates()) {
|
| | | assertEquals(Status.OK, update.getStatus());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | |
| | | }
|
| | |
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/test/jgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/test/jgit.git", url));
|
| | | clone.setDirectory(jgitFolder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | w.close();
|
| | | git.add().addFilepattern(file.getName()).call();
|
| | | git.commit().setMessage("test commit").call();
|
| | | git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | Iterable<PushResult> results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | GitBlitSuite.close(git);
|
| | | for (PushResult result : results) {
|
| | | for (RemoteRefUpdate update : result.getRemoteUpdates()) {
|
| | | assertEquals(Status.OK, update.getStatus());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | |
| | | }
|
| | |
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/test/jgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/test/jgit.git", url));
|
| | | clone.setDirectory(jgitFolder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | git.add().addFilepattern(file.getName()).call();
|
| | | git.commit().setMessage("test commit").call();
|
| | |
|
| | | try {
|
| | | git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | assertTrue(false);
|
| | | } catch (Exception e) {
|
| | | assertTrue(e.getCause().getMessage().contains("access forbidden"));
|
| | | Iterable<PushResult> results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | for (PushResult result : results) {
|
| | | for (RemoteRefUpdate update : result.getRemoteUpdates()) {
|
| | | assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
|
| | | }
|
| | | }
|
| | |
|
| | | // unfreeze repo
|
| | | model.isFrozen = false;
|
| | | GitBlit.self().updateRepositoryModel(model.name, model, false);
|
| | |
|
| | | git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | GitBlitSuite.close(git);
|
| | | for (PushResult result : results) {
|
| | | for (RemoteRefUpdate update : result.getRemoteUpdates()) {
|
| | | assertEquals(Status.OK, update.getStatus());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void testPushToNonBareRepository() throws Exception {
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/working/jgit", url));
|
| | | clone.setURI(MessageFormat.format("{0}/working/jgit", url));
|
| | | clone.setDirectory(jgit2Folder);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | w.close();
|
| | | git.add().addFilepattern(file.getName()).call();
|
| | | git.commit().setMessage("test commit followed by push to non-bare repository").call();
|
| | | try {
|
| | | git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | assertTrue(false);
|
| | | } catch (Exception e) {
|
| | | assertTrue(e.getCause().getMessage().contains("git-receive-pack not permitted"));
|
| | | }
|
| | | Iterable<PushResult> results = git.push().setPushAll().setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password)).call();
|
| | | GitBlitSuite.close(git);
|
| | | for (PushResult result : results) {
|
| | | for (RemoteRefUpdate update : result.getRemoteUpdates()) {
|
| | | assertEquals(Status.REJECTED_OTHER_REASON, update.getStatus());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | |
| | | FileUtils.delete(verification, FileUtils.RECURSIVE);
|
| | | }
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(verification);
|
| | | clone.setBare(true);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | FileUtils.delete(local, FileUtils.RECURSIVE);
|
| | | }
|
| | | clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/{1}", url, model.name));
|
| | | clone.setURI(MessageFormat.format("{0}/{1}", url, model.name));
|
| | | clone.setDirectory(local);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | FileUtils.delete(refChecks, FileUtils.RECURSIVE);
|
| | | }
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(refChecks);
|
| | | clone.setBare(true);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | FileUtils.delete(local, FileUtils.RECURSIVE);
|
| | | }
|
| | | clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/{1}", url, model.name));
|
| | | clone.setURI(MessageFormat.format("{0}/{1}", url, model.name));
|
| | | clone.setDirectory(local);
|
| | | clone.setBare(false);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | }
|
| | |
|
| | | CloneCommand clone = Git.cloneRepository();
|
| | | clone.setURI(MessageFormat.format("{0}/git/ticgit.git", url));
|
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
|
| | | clone.setDirectory(createCheck);
|
| | | clone.setBare(true);
|
| | | clone.setCloneAllBranches(true);
|
| | |
| | | GitBlitSuite.close(personalRepo);
|
| | |
|
| | | // add a personal repository remote and a project remote
|
| | | git.getRepository().getConfig().setString("remote", "user", "url", MessageFormat.format("{0}/git/~{1}/ticgit.git", url, user.username));
|
| | | git.getRepository().getConfig().setString("remote", "project", "url", MessageFormat.format("{0}/git/project/ticgit.git", url));
|
| | | git.getRepository().getConfig().setString("remote", "user", "url", MessageFormat.format("{0}/~{1}/ticgit.git", url, user.username));
|
| | | git.getRepository().getConfig().setString("remote", "project", "url", MessageFormat.format("{0}/project/ticgit.git", url));
|
| | | git.getRepository().getConfig().save();
|
| | |
|
| | | // push to non-existent user repository
|