credentialsProvider = new UsernamePasswordCredentialsProvider(username, password); } else { credentialsProvider = CredentialsProvider.getDefault();
/** * Create a minimal transport instance not tied to a single repository. * * @param uri * a {@link org.eclipse.jgit.transport.URIish} object. */ protected Transport(URIish uri) { this.uri = uri; this.local = null; this.objectChecker = new ObjectChecker(); this.credentialsProvider = CredentialsProvider.getDefault(); }
/** * <p>Constructor for TransportCommand.</p> * * @param repo a {@link org.eclipse.jgit.lib.Repository} object. */ protected TransportCommand(Repository repo) { super(repo); setCredentialsProvider(CredentialsProvider.getDefault()); }
/** * Create a new transport instance. * * @param local * the repository this instance will fetch into, or push out of. * This must be the repository passed to * {@link #open(Repository, URIish)}. * @param uri * the URI used to access the remote repository. This must be the * URI passed to {@link #open(Repository, URIish)}. */ protected Transport(Repository local, URIish uri) { final TransferConfig tc = local.getConfig().get(TransferConfig.KEY); this.local = local; this.uri = uri; this.objectChecker = tc.newObjectChecker(); this.credentialsProvider = CredentialsProvider.getDefault(); prePush = Hooks.prePush(local, hookOutRedirect); }
/** * @param repo */ protected TransportCommand(final Repository repo) { super(repo); setCredentialsProvider(CredentialsProvider.getDefault()); }
/** * Create a minimal transport instance not tied to a single repository. * * @param uri */ protected Transport(final URIish uri) { this.uri = uri; this.local = null; this.objectChecker = new ObjectChecker(); this.credentialsProvider = CredentialsProvider.getDefault(); }
/** * Create a minimal transport instance not tied to a single repository. * * @param uri * a {@link org.eclipse.jgit.transport.URIish} object. */ protected Transport(URIish uri) { this.uri = uri; this.local = null; this.objectChecker = new ObjectChecker(); this.credentialsProvider = CredentialsProvider.getDefault(); }
/** * <p>Constructor for TransportCommand.</p> * * @param repo a {@link org.eclipse.jgit.lib.Repository} object. */ protected TransportCommand(Repository repo) { super(repo); setCredentialsProvider(CredentialsProvider.getDefault()); }
private CredentialsProvider buildCredential( final Map<String, ?> env ) { if ( env != null ) { if ( env.containsKey( USER_NAME ) ) { if ( env.containsKey( PASSWORD ) ) { return new UsernamePasswordCredentialsProvider( env.get( USER_NAME ).toString(), env.get( PASSWORD ).toString() ); } return new UsernamePasswordCredentialsProvider( env.get( USER_NAME ).toString(), "" ); } } return CredentialsProvider.getDefault(); }
private CredentialsProvider buildCredential(String username, String password) { if (username != null) { if (password != null) { return new UsernamePasswordCredentialsProvider(username, password); } return new UsernamePasswordCredentialsProvider(username, ""); } return CredentialsProvider.getDefault(); }
@Test(expected = UnsupportedOperationException.class) public void testGetPathMatcher() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); fileSystem.getPathMatcher( "*" ); } }
@Test(expected = UnsupportedOperationException.class) public void testGetUserPrincipalLookupService() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); fileSystem.getUserPrincipalLookupService(); }
@Test(expected = UnsupportedOperationException.class) @Ignore public void testNewWatchService() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); fileSystem.newWatchService(); }
@Test(expected = UnsupportedOperationException.class) public void testGetPathMatcher() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); fileSystem.getPathMatcher("*"); }
@Test(expected = UnsupportedOperationException.class) public void testGetUserPrincipalLookupService() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); fileSystem.getUserPrincipalLookupService(); }
@Test public void testPathEqualsWithDifferentRepos() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final Git git1 = setupGit(); final JGitFileSystem fileSystem1 = new JGitFileSystem( fsProvider, null, git1, "my-repo1", CredentialsProvider.getDefault() ); final Git git2 = setupGit(); final JGitFileSystem fileSystem2 = new JGitFileSystem( fsProvider, null, git2, "my-repo2", CredentialsProvider.getDefault() ); final Path path1 = fileSystem1.getPath( "master", "/path/to/some.txt" ); final Path path2 = fileSystem2.getPath( "master", "/path/to/some.txt" ); assertThat( path1 ).isNotEqualTo( path2 ); assertThat( path1 ).isEqualTo( fileSystem1.getPath( "/path/to/some.txt" ) ); }
@Test public void testFileStore() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final File tempDir = createTempDirectory(); final Git git = setupGit( tempDir ); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); assertThat( fileSystem.getFileStores() ).hasSize( 1 ); final FileStore fileStore = fileSystem.getFileStores().iterator().next(); assertThat( fileStore ).isNotNull(); assertThat( fileStore.getTotalSpace() ).isEqualTo( tempDir.getTotalSpace() ); assertThat( fileStore.getUsableSpace() ).isEqualTo( tempDir.getUsableSpace() ); }
@Test public void testOnlyLocalRoot() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); assertThat( fileSystem.isReadOnly() ).isFalse(); assertThat( fileSystem.getSeparator() ).isEqualTo( "/" ); assertThat( fileSystem.getName() ).isEqualTo( "my-repo" ); assertThat( fileSystem.getRootDirectories() ).hasSize( 1 ); final Path root = fileSystem.getRootDirectories().iterator().next(); assertThat( root.toString() ).isEqualTo( "/" ); assertThat( root.getRoot().toString() ).isEqualTo( "/" ); }
@Test public void testProvider() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); assertThat( fileSystem.getName() ).isEqualTo( "my-repo" ); assertThat( fileSystem.isReadOnly() ).isFalse(); assertThat( fileSystem.getSeparator() ).isEqualTo( "/" ); assertThat( fileSystem.provider() ).isEqualTo( fsProvider ); }
@Test public void testSupportedFileAttributeViews() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); assertThat( fileSystem.isReadOnly() ).isFalse(); assertThat( fileSystem.getSeparator() ).isEqualTo( "/" ); assertThat( fileSystem.getName() ).isEqualTo( "my-repo" ); assertThat( fileSystem.supportedFileAttributeViews() ).isNotEmpty().hasSize( 2 ).contains( "basic", "version" ); }