wagon.connect( new Repository( repository.getId(), repository.getUrl() ), authenticationInfo( repository ), proxyInfo( repository ) ); wagon.connect( new Repository( repository.getId(), repository.getUrl() ), authenticationInfo( repository ) ); wagon.connect( new Repository( repository.getId(), repository.getUrl() ), proxyInfo( repository ) ); wagon.connect( new Repository( repository.getId(), repository.getUrl() ) );
private org.apache.maven.settings.Proxy getProxy( ArtifactRepository repository, List<org.apache.maven.settings.Proxy> proxies ) { if ( proxies != null && repository.getProtocol() != null ) { for ( org.apache.maven.settings.Proxy proxy : proxies ) { if ( proxy.isActive() && repository.getProtocol().equalsIgnoreCase( proxy.getProtocol() ) ) { if ( StringUtils.isNotEmpty( proxy.getNonProxyHosts() ) ) { ProxyInfo pi = new ProxyInfo(); pi.setNonProxyHosts( proxy.getNonProxyHosts() ); org.apache.maven.wagon.repository.Repository repo = new org.apache.maven.wagon.repository.Repository( repository.getId(), repository.getUrl() ); if ( !ProxyUtils.validateNonProxyHosts( pi, repo.getHost() ) ) { return proxy; } } else { return proxy; } } } } return null; }
File repoDir = new File("test-git/.git"); // open the repository Repository repo = new Repository(repoDir); // find the HEAD Commit head = repo.mapCommit(Constants.HEAD); // retrieve the tree in HEAD Tree tree = head.getTree(); // 1.2.0 api version here // find a file (as a TreeEntry, which contains the blob object id) TreeWalk treewalk = TreeWalk.forPath(repo, "b/test.txt", tree); // use the blob id to read the file's data byte[] data = repo.open(treewalk.getObjectId(0)).getBytes();
File repoDir = new File("test-git"); // open the repository Repository repository = new Repository(repoDir); // find the HEAD ObjectId lastCommitId = repository.resolve(Constants.HEAD); // now we have to get the commit RevWalk revWalk = new RevWalk(repository); RevCommit commit = revWalk.parseCommit(lastCommitId); // and using commit's tree find the path RevTree tree = commit.getTree(); TreeWalk treeWalk = new TreeWalk(repository); treeWalk.addTree(tree); treeWalk.setRecursive(true); treeWalk.setFilter(PathFilter.create(path)); if (!treeWalk.next()) { return null; } ObjectId objectId = treeWalk.getObjectId(0); ObjectLoader loader = repository.open(objectId); // and then one can use either InputStream in = loader.openStream() // or loader.copyTo(out)
public class BitbucketService implements GitService { @Override public List<Repository> fetchRepositories() { // Time consuming / IO consuming task. try { Thread.sleep(2000); } catch (InterruptedException e) { // Swallow exception. } List<Repository> result = new ArrayList<>(); result.add(new Repository("http://some-fancy-repository.com/")); return result; } }
public class GithubService implements GitService { @Override public List<Repository> fetchRepositories() { // Time consuming / IO consuming task. try { Thread.sleep(2000); } catch (InterruptedException e) { // Swallow exception. } List<Repository> result = new ArrayList<>(); result.add(new Repository("http://some-fancier-repository.com/")); return result; } }
public ControllerTest { @Test public shouldDoTestOfShowView() { Controller controller = new Controller(); Repository repository = new Repository(); ReflectionTestUtils.setField(controller, "repo", repository); } }
protected Repository createFileRepository( String url ) { File path = new File( url.substring( 7 ) ); path.mkdirs(); Repository repository = new Repository(); repository.setUrl( url ); return repository; }
protected Repository createFileRepository( String url ) { File path = new File( url.substring( 7 ) ); path.mkdirs(); Repository repository = new Repository(); repository.setUrl( url ); return repository; }
RevWalk rw = new RevWalk(new Repository( new File("/path/to/git"))); RevCommit c = null; AnyObjectId headId; try { headId = git.resolve(Constants.HEAD); RevCommit root = rw.parseCommit(headId); rw.sort(RevSort.REVERSE); rw.markStart(root); c = rw.next(); } catch (IOException e) { e.printStackTrace(); }
File repoDir = new File("test-git/.git"); // open the repository Repository repo = new Repository(repoDir); // find the HEAD Commit head = repo.mapCommit(Constants.HEAD); // retrieve the tree in HEAD Tree tree = head.getTree(); // find a file (as a TreeEntry, which contains the blob object id) TreeEntry entry = tree.findBlobMember("b/test.txt"); // use the blob id to read the file's data byte[] data = repo.openBlob(entry.getId()).getBytes();
public WagonHttpRepository(Log log,WagonManager wagonManager) throws ConnectionException, AuthenticationException, WagonConfigurationException, UnsupportedProtocolException { this.log = log; this.rep = new Repository(URL_REPO, URL_REPO); this.w = wagonManager.getWagon(rep); w.connect(rep, wagonManager.getProxy(rep.getProtocol())); }
public void deploy() throws ComponentLookupException, ConnectionException, AuthenticationException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Repository repository = new Repository(); repository.setUrl( repositoryUrl ); wagon.connect( repository, getWagonAuthenticationInfo() ); wagon.put( fileToDeploy, artifactPath ); wagon.disconnect(); }
public void testConnect() throws Exception { getWagon().connect( new Repository( "foo", getTestRepositoryUrl() ), getAuthInfo() ); assertTrue( true ); }
public void deploy() throws ComponentLookupException, ConnectionException, AuthenticationException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Repository repository = new Repository(); repository.setUrl(repositoryUrl); wagon.connect(repository, getWagonAuthenticationInfo()); wagon.put(fileToDeploy, artifactPath); wagon.disconnect(); }
public void testConnect() throws Exception { getWagon().connect( new Repository( "foo", getTestRepositoryUrl() ), getAuthInfo() ); assertTrue( true ); }
protected void setUp() throws Exception { super.setUp(); source = new Repository( "test", "scp://" + TestData.getUserName() + "@" + TestData.getHostname() + "/tmp/foo" ); wagon = (SshWagon) lookup( Wagon.ROLE, "scp" ); wagon.setInteractive( false ); this.okHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CORRECT_KEY ); this.failHostsProvider = new SingleKnownHostProvider( "beaver.codehaus.org", CORRECT_KEY ); this.changedHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CHANGED_KEY ); } }
protected void setUp() throws Exception { super.setUp(); source = new Repository( "test", "scp://" + TestData.getUserName() + "@" + TestData.getHostname() + "/tmp/foo" ); wagon = (SshWagon) lookup( Wagon.ROLE, "scp" ); wagon.setInteractive( false ); this.okHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CORRECT_KEY ); this.failHostsProvider = new SingleKnownHostProvider( "beaver.codehaus.org", CORRECT_KEY ); this.changedHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CHANGED_KEY ); } }
@Test @Ignore public void testPermissions() { try { AuthenticationInfo auth = new AuthenticationInfo(); auth.setUserName(USERNAME); auth.setPassword(PASSWORD); Repository repository = new Repository("kuali.release", "s3://deletemenow.kuali.org/release"); S3Wagon wagon = new S3Wagon(); wagon.connect(repository, auth); } catch (Exception e) { e.printStackTrace(); } }
@Test @Ignore public void testPermissions() { try { AuthenticationInfo auth = new AuthenticationInfo(); auth.setUserName(USERNAME); auth.setPassword(PASSWORD); Repository repository = new Repository("kuali.external", "s3://maven.kuali.org/external"); S3Wagon wagon = new S3Wagon(); wagon.connect(repository, auth); } catch (Exception e) { e.printStackTrace(); } }