Skip to content

Commit 25dbcbb

Browse files
chore: remove unused getAuthor..., getCommitter..., and getFullMessage
1 parent bef1740 commit 25dbcbb

File tree

6 files changed

+5
-350
lines changed

6 files changed

+5
-350
lines changed

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/GitClientGitInfoBuilder.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,7 @@ public GitInfo build(@Nullable String repositoryPath) {
3939
List<String> tags = gitClient.getTags(GitClient.HEAD);
4040
String tag = !tags.isEmpty() ? tags.iterator().next() : null;
4141

42-
String currentCommitSha = gitClient.getSha(GitClient.HEAD);
43-
String fullMessage = gitClient.getFullMessage(GitClient.HEAD);
44-
45-
String authorName = gitClient.getAuthorName(GitClient.HEAD);
46-
String authorEmail = gitClient.getAuthorEmail(GitClient.HEAD);
47-
String authorDate = gitClient.getAuthorDate(GitClient.HEAD);
48-
PersonInfo author = new PersonInfo(authorName, authorEmail, authorDate);
49-
50-
String committerName = gitClient.getCommitterName(GitClient.HEAD);
51-
String committerEmail = gitClient.getCommitterEmail(GitClient.HEAD);
52-
String committerDate = gitClient.getCommitterDate(GitClient.HEAD);
53-
PersonInfo committer = new PersonInfo(committerName, committerEmail, committerDate);
54-
55-
CommitInfo commitInfo = new CommitInfo(currentCommitSha, author, committer, fullMessage);
42+
CommitInfo commitInfo = gitClient.getCommitInfo(GitClient.HEAD);
5643
return new GitInfo(remoteUrl, branch, tag, commitInfo);
5744

5845
} catch (Exception e) {

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/GitClient.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,6 @@ void unshallow(@Nullable String remoteCommitReference, boolean onlyFetchCommit)
4141
@Nullable
4242
String getSha(String reference) throws IOException, TimeoutException, InterruptedException;
4343

44-
@Nullable
45-
String getFullMessage(String commit) throws IOException, TimeoutException, InterruptedException;
46-
47-
@Nullable
48-
String getAuthorName(String commit) throws IOException, TimeoutException, InterruptedException;
49-
50-
@Nullable
51-
String getAuthorEmail(String commit) throws IOException, TimeoutException, InterruptedException;
52-
53-
@Nullable
54-
String getAuthorDate(String commit) throws IOException, TimeoutException, InterruptedException;
55-
56-
@Nullable
57-
String getCommitterName(String commit) throws IOException, TimeoutException, InterruptedException;
58-
59-
@Nullable
60-
String getCommitterEmail(String commit)
61-
throws IOException, TimeoutException, InterruptedException;
62-
63-
@Nullable
64-
String getCommitterDate(String commit) throws IOException, TimeoutException, InterruptedException;
65-
6644
@Nonnull
6745
CommitInfo getCommitInfo(String commit)
6846
throws IOException, TimeoutException, InterruptedException;

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/NoOpGitClient.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -67,48 +67,6 @@ public String getSha(String reference) {
6767
return null;
6868
}
6969

70-
@Nullable
71-
@Override
72-
public String getFullMessage(String commit) {
73-
return null;
74-
}
75-
76-
@Nullable
77-
@Override
78-
public String getAuthorName(String commit) {
79-
return null;
80-
}
81-
82-
@Nullable
83-
@Override
84-
public String getAuthorEmail(String commit) {
85-
return null;
86-
}
87-
88-
@Nullable
89-
@Override
90-
public String getAuthorDate(String commit) {
91-
return null;
92-
}
93-
94-
@Nullable
95-
@Override
96-
public String getCommitterName(String commit) {
97-
return null;
98-
}
99-
100-
@Nullable
101-
@Override
102-
public String getCommitterEmail(String commit) {
103-
return null;
104-
}
105-
106-
@Nullable
107-
@Override
108-
public String getCommitterDate(String commit) {
109-
return null;
110-
}
111-
11270
@Nonnull
11371
@Override
11472
public CommitInfo getCommitInfo(String commit) {

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/ShellGitClient.java

Lines changed: 0 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -318,181 +318,6 @@ public String getSha(String reference)
318318
.trim());
319319
}
320320

321-
/**
322-
* Returns full message of the provided commit
323-
*
324-
* @param commit Commit SHA or reference (HEAD, branch name, etc) to check
325-
* @return full message of the provided commit
326-
* @throws IOException If an error was encountered while writing command input or reading output
327-
* @throws TimeoutException If timeout was reached while waiting for Git command to finish
328-
* @throws InterruptedException If current thread was interrupted while waiting for Git command to
329-
* finish
330-
*/
331-
@Nullable
332-
@Override
333-
public String getFullMessage(String commit)
334-
throws IOException, TimeoutException, InterruptedException {
335-
if (GitUtils.isNotValidCommit(commit)) {
336-
return null;
337-
}
338-
return executeCommand(
339-
Command.OTHER,
340-
() ->
341-
commandExecutor
342-
.executeCommand(IOUtils::readFully, "git", "log", "-n", "1", "--format=%B", commit)
343-
.trim());
344-
}
345-
346-
/**
347-
* Returns author name for the provided commit
348-
*
349-
* @param commit Commit SHA or reference (HEAD, branch name, etc) to check
350-
* @return author name for the provided commit
351-
* @throws IOException If an error was encountered while writing command input or reading output
352-
* @throws TimeoutException If timeout was reached while waiting for Git command to finish
353-
* @throws InterruptedException If current thread was interrupted while waiting for Git command to
354-
* finish
355-
*/
356-
@Nullable
357-
@Override
358-
public String getAuthorName(String commit)
359-
throws IOException, TimeoutException, InterruptedException {
360-
if (GitUtils.isNotValidCommit(commit)) {
361-
return null;
362-
}
363-
return executeCommand(
364-
Command.OTHER,
365-
() ->
366-
commandExecutor
367-
.executeCommand(IOUtils::readFully, "git", "log", "-n", "1", "--format=%an", commit)
368-
.trim());
369-
}
370-
371-
/**
372-
* Returns author email for the provided commit
373-
*
374-
* @param commit Commit SHA or reference (HEAD, branch name, etc) to check
375-
* @return author email for the provided commit
376-
* @throws IOException If an error was encountered while writing command input or reading output
377-
* @throws TimeoutException If timeout was reached while waiting for Git command to finish
378-
* @throws InterruptedException If current thread was interrupted while waiting for Git command to
379-
* finish
380-
*/
381-
@Nullable
382-
@Override
383-
public String getAuthorEmail(String commit)
384-
throws IOException, TimeoutException, InterruptedException {
385-
if (GitUtils.isNotValidCommit(commit)) {
386-
return null;
387-
}
388-
return executeCommand(
389-
Command.OTHER,
390-
() ->
391-
commandExecutor
392-
.executeCommand(IOUtils::readFully, "git", "log", "-n", "1", "--format=%ae", commit)
393-
.trim());
394-
}
395-
396-
/**
397-
* Returns author date in strict ISO 8601 format for the provided commit
398-
*
399-
* @param commit Commit SHA or reference (HEAD, branch name, etc) to check
400-
* @return author date in strict ISO 8601 format
401-
* @throws IOException If an error was encountered while writing command input or reading output
402-
* @throws TimeoutException If timeout was reached while waiting for Git command to finish
403-
* @throws InterruptedException If current thread was interrupted while waiting for Git command to
404-
* finish
405-
*/
406-
@Nullable
407-
@Override
408-
public String getAuthorDate(String commit)
409-
throws IOException, TimeoutException, InterruptedException {
410-
if (GitUtils.isNotValidCommit(commit)) {
411-
return null;
412-
}
413-
return executeCommand(
414-
Command.OTHER,
415-
() ->
416-
commandExecutor
417-
.executeCommand(IOUtils::readFully, "git", "log", "-n", "1", "--format=%aI", commit)
418-
.trim());
419-
}
420-
421-
/**
422-
* Returns committer name for the provided commit
423-
*
424-
* @param commit Commit SHA or reference (HEAD, branch name, etc) to check
425-
* @return committer name for the provided commit
426-
* @throws IOException If an error was encountered while writing command input or reading output
427-
* @throws TimeoutException If timeout was reached while waiting for Git command to finish
428-
* @throws InterruptedException If current thread was interrupted while waiting for Git command to
429-
* finish
430-
*/
431-
@Nullable
432-
@Override
433-
public String getCommitterName(String commit)
434-
throws IOException, TimeoutException, InterruptedException {
435-
if (GitUtils.isNotValidCommit(commit)) {
436-
return null;
437-
}
438-
return executeCommand(
439-
Command.OTHER,
440-
() ->
441-
commandExecutor
442-
.executeCommand(IOUtils::readFully, "git", "log", "-n", "1", "--format=%cn", commit)
443-
.trim());
444-
}
445-
446-
/**
447-
* Returns committer email for the provided commit
448-
*
449-
* @param commit Commit SHA or reference (HEAD, branch name, etc) to check
450-
* @return committer email for the provided commit
451-
* @throws IOException If an error was encountered while writing command input or reading output
452-
* @throws TimeoutException If timeout was reached while waiting for Git command to finish
453-
* @throws InterruptedException If current thread was interrupted while waiting for Git command to
454-
* finish
455-
*/
456-
@Nullable
457-
@Override
458-
public String getCommitterEmail(String commit)
459-
throws IOException, TimeoutException, InterruptedException {
460-
if (GitUtils.isNotValidCommit(commit)) {
461-
return null;
462-
}
463-
return executeCommand(
464-
Command.OTHER,
465-
() ->
466-
commandExecutor
467-
.executeCommand(IOUtils::readFully, "git", "log", "-n", "1", "--format=%ce", commit)
468-
.trim());
469-
}
470-
471-
/**
472-
* Returns committer date in strict ISO 8601 format for the provided commit
473-
*
474-
* @param commit Commit SHA or reference (HEAD, branch name, etc) to check
475-
* @return committer date in strict ISO 8601 format
476-
* @throws IOException If an error was encountered while writing command input or reading output
477-
* @throws TimeoutException If timeout was reached while waiting for Git command to finish
478-
* @throws InterruptedException If current thread was interrupted while waiting for Git command to
479-
* finish
480-
*/
481-
@Nullable
482-
@Override
483-
public String getCommitterDate(String commit)
484-
throws IOException, TimeoutException, InterruptedException {
485-
if (GitUtils.isNotValidCommit(commit)) {
486-
return null;
487-
}
488-
return executeCommand(
489-
Command.OTHER,
490-
() ->
491-
commandExecutor
492-
.executeCommand(IOUtils::readFully, "git", "log", "-n", "1", "--format=%cI", commit)
493-
.trim());
494-
}
495-
496321
/**
497322
* Returns commit information for the provided commit
498323
*

dd-java-agent/agent-ci-visibility/src/test/groovy/datadog/trace/civisibility/CiVisibilityRepoServicesTest.groovy

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,7 @@ class CiVisibilityRepoServicesTest extends Specification {
5959

6060
def gitClient = Stub(GitClient)
6161
gitClient.getMergeBase("targetSha", "sourceSha") >> expectedInfo.getPullRequestBaseBranchSha()
62-
gitClient.getAuthorName("sourceSha") >> expectedInfo.getGitCommitHead().getAuthor().getName()
63-
gitClient.getAuthorEmail("sourceSha") >> expectedInfo.getGitCommitHead().getAuthor().getEmail()
64-
gitClient.getAuthorDate("sourceSha") >> expectedInfo.getGitCommitHead().getAuthor().getIso8601Date()
65-
gitClient.getCommitterName("sourceSha") >> expectedInfo.getGitCommitHead().getCommitter().getName()
66-
gitClient.getCommitterEmail("sourceSha") >> expectedInfo.getGitCommitHead().getCommitter().getEmail()
67-
gitClient.getCommitterDate("sourceSha") >> expectedInfo.getGitCommitHead().getCommitter().getIso8601Date()
68-
gitClient.getFullMessage("sourceSha") >> expectedInfo.getGitCommitHead().getFullMessage()
62+
gitClient.getCommitInfo("sourceSha") >> expectedInfo.getGitCommitHead()
6963

7064
expect:
7165
CiVisibilityRepoServices.buildPullRequestInfo(config, environment, ciProviderInfo, gitClient, repoUnshallow) == expectedInfo

0 commit comments

Comments
 (0)