Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@
<version>27.1-jre</version>
</dependency>

<!-- HttpClient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>

<!-- JGit -->
<dependency>
<groupId>org.eclipse.jgit</groupId>
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/pl/project13/maven/git/GitDataProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package pl.project13.maven.git;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.apache.http.client.utils.URIBuilder;
import pl.project13.maven.git.build.BuildServerDataProvider;
import pl.project13.maven.git.build.UnknownBuildServerData;
import pl.project13.maven.git.log.LoggerBridge;
Expand Down Expand Up @@ -53,7 +52,7 @@ public abstract class GitDataProvider implements GitProvider {
protected CommitIdGenerationMode commitIdGenerationMode;

protected String evaluateOnCommit;

protected boolean useBranchNameFromBuildEnvironment;

protected List<String> excludeProperties;
Expand Down Expand Up @@ -95,7 +94,7 @@ public GitDataProvider setDateFormatTimeZone(String dateFormatTimeZone) {
this.dateFormatTimeZone = dateFormatTimeZone;
return this;
}

public GitDataProvider setUseBranchNameFromBuildEnvironment(boolean useBranchNameFromBuildEnvironment) {
this.useBranchNameFromBuildEnvironment = useBranchNameFromBuildEnvironment;
return this;
Expand Down Expand Up @@ -309,13 +308,18 @@ protected String stripCredentialsFromOriginUrl(String gitRemoteString) throws Gi
if (null == userInfoString) {
return gitRemoteString;
}
URIBuilder b = new URIBuilder(gitRemoteString);

String[] userInfo = userInfoString.split(":");
// Build a new URL from the original URL, but nulling out the password
// component of the userinfo. We keep the username so that ssh uris such
// ssh://[email protected] will retain 'git@'.
b.setUserInfo(userInfo[0]);
return b.build().toString();
return new URI(original.getScheme(),
userInfo[0],
original.getHost(),
original.getPort(),
original.getPath(),
original.getQuery(),
original.getFragment()).toString();

} catch (URISyntaxException e) {
log.error("Something went wrong to strip the credentials from git's remote url (please report this)!", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static Collection<Object[]> parameters() {

@Test
@Parameters(method = "parameters")
public void testStripCrecentialsFromOriginUrl(String input, String expected) throws GitCommitIdExecutionException {
public void testStripCredentialsFromOriginUrl(String input, String expected) throws GitCommitIdExecutionException {
GitDataProvider gitDataProvider = mock(GitDataProvider.class);
when(gitDataProvider.stripCredentialsFromOriginUrl(ArgumentMatchers.any())).thenCallRealMethod();
String result = gitDataProvider.stripCredentialsFromOriginUrl(input);
Expand Down