diff --git a/docs/dg/settingUp.md b/docs/dg/settingUp.md index f32e3de3e9..a82a04e90b 100644 --- a/docs/dg/settingUp.md +++ b/docs/dg/settingUp.md @@ -11,7 +11,7 @@ **Prerequisites:** * **JDK `1.8.0_60`** up to **`17`** ([download :fas-download:](https://www.oracle.com/technetwork/java/javase/downloads/index.html)). * **Node.js** `16.19.1` to the latest minor version for `18` ([download :fas-download:](https://www.npmjs.com/get-npm)). -* **git `2.14`** or later ([download :fas-download:](https://git-scm.com/downloads)). +* **git `2.23`** or later ([download :fas-download:](https://git-scm.com/downloads)). diff --git a/docs/ug/cli.md b/docs/ug/cli.md index a1e4a55956..2deb769b4b 100644 --- a/docs/ug/cli.md +++ b/docs/ug/cli.md @@ -84,12 +84,6 @@ Binary file formats, such as `jpg`, `png`,`exe`,`zip`, `rar`, `docx`, and `pptx` * Alias: `-F` (uppercase F) * Example:`--find-previous-authors` or `-F` - - -* This flag only works on **git `2.23`** or later. -* If an earlier version of **git** is used, RepoSense can still run but this flag will be ignored. - - ### `--help`, `-h` diff --git a/docs/ug/generatingReports.md b/docs/ug/generatingReports.md index f4bb88f557..75137da9a5 100644 --- a/docs/ug/generatingReports.md +++ b/docs/ug/generatingReports.md @@ -30,7 +30,7 @@ For other types of repositories, external links are disabled. 1. **Ensure you have the prerequisites**: * **Java 8** (JRE `1.8.0_60`) or later ([download :fas-download:](https://www.java.com/en/)). - * **git `2.14`** or later on the command line. ([download :fas-download:](https://git-scm.com/downloads)).
run `git --version` in your OS terminal to confirm the version. + * **git `2.23`** or later on the command line. ([download :fas-download:](https://git-scm.com/downloads)).
run `git --version` in your OS terminal to confirm the version. 1. **Download the latest JAR file** from our [releases](https://github.com/reposense/RepoSense/releases/latest). diff --git a/src/main/java/reposense/RepoSense.java b/src/main/java/reposense/RepoSense.java index 63cfdd92ff..c27103e013 100644 --- a/src/main/java/reposense/RepoSense.java +++ b/src/main/java/reposense/RepoSense.java @@ -10,7 +10,6 @@ import net.sourceforge.argparse4j.helper.HelpScreenException; import reposense.git.GitConfig; -import reposense.git.GitVersion; import reposense.model.CliArguments; import reposense.model.RepoConfiguration; import reposense.model.ReportConfiguration; @@ -33,8 +32,6 @@ public class RepoSense { private static final int SERVER_PORT_NUMBER = 9000; private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("E MMM d HH:mm:ss yyyy z"); private static final String VERSION_UNSPECIFIED = "unspecified"; - private static final String FINDING_PREVIOUS_AUTHORS_INVALID_VERSION_WARNING_MESSAGE = - "--find-previous-authors/-F requires git version 2.23 and above. Feature will be disabled for this run"; /** * The entry point of the program. @@ -69,12 +66,6 @@ public static void main(String[] args) { RepoConfiguration.setIsFindingPreviousAuthorsPerformedToRepoConfigs(configs, cliArguments.isFindingPreviousAuthorsPerformed()); - if (RepoConfiguration.isAnyRepoFindingPreviousAuthors(configs) - && !GitVersion.isGitVersionSufficientForFindingPreviousAuthors()) { - logger.warning(FINDING_PREVIOUS_AUTHORS_INVALID_VERSION_WARNING_MESSAGE); - RepoConfiguration.setToFalseIsFindingPreviousAuthorsPerformedToRepoConfigs(configs); - } - List globalGitConfig = GitConfig.getGlobalGitLfsConfig(); if (globalGitConfig.size() != 0) { GitConfig.setGlobalGitLfsConfig(GitConfig.SKIP_SMUDGE_CONFIG_SETTINGS); diff --git a/src/main/java/reposense/git/GitVersion.java b/src/main/java/reposense/git/GitVersion.java deleted file mode 100644 index d97e2c0758..0000000000 --- a/src/main/java/reposense/git/GitVersion.java +++ /dev/null @@ -1,69 +0,0 @@ -package reposense.git; - -import static reposense.system.CommandRunner.runCommand; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Contains git version related functionalities. - * Git version is responsible for finding out the version of git the user of RepoSense is running. - */ -public class GitVersion { - - /** Regex for finding Git Version. */ - private static final Pattern GIT_VERSION_PATTERN = - Pattern.compile("^git version (?\\d+)\\.(?\\d+).*?\n?$"); - private static final String VERSION_NUMBER_GROUP = "versionNumber"; - private static final String RELEASE_NUMBER_GROUP = "releaseNumber"; - - /** - * Get current git version of RepoSense user. - */ - public static String getGitVersion() { - Path rootPath = Paths.get("/"); - String versionCommand = "git --version"; - - return runCommand(rootPath, versionCommand); - } - - /** - * Returns the version number and release number from a git version {@code commandOutput}. - * Return type is a length 2 string array with the version number at index 0, release number at index 1. - */ - protected static String[] getVersionNumberAndReleaseNumberFromString(String commandOutput) { - Matcher matcher = GIT_VERSION_PATTERN.matcher(commandOutput); - matcher.matches(); - return new String[] {matcher.group(VERSION_NUMBER_GROUP), matcher.group(RELEASE_NUMBER_GROUP)}; - } - - /** - * Returns true if the {@code commandOutput} version is at least as recent as the {@code versionString} version. - */ - protected static boolean isGitVersionOutputAtLeastVersion(String commandOutput, String versionString) { - String[] versionStringDetails = versionString.split("\\."); - int requiredVersionNumber = Integer.parseInt(versionStringDetails[0]); - int requiredReleaseNumber = Integer.parseInt(versionStringDetails[1]); - String[] gitVersionCommandOutputDetails = getVersionNumberAndReleaseNumberFromString(commandOutput); - int actualVersionNumber = Integer.parseInt(gitVersionCommandOutputDetails[0]); - int actualReleaseNumber = Integer.parseInt(gitVersionCommandOutputDetails[1]); - return actualVersionNumber > requiredVersionNumber - || actualVersionNumber == requiredVersionNumber && actualReleaseNumber >= requiredReleaseNumber; - } - - /** - * Returns true if the machine's Git version is at least as recent as {@code versionString}. - */ - public static boolean isGitVersionAtLeast(String versionString) { - return isGitVersionOutputAtLeastVersion(getGitVersion(), versionString); - } - - /** - * Returns true if the machine's Git version is sufficient for finding previous authors. - */ - public static boolean isGitVersionSufficientForFindingPreviousAuthors() { - return isGitVersionAtLeast("2.23"); - } -} diff --git a/src/main/java/reposense/model/RepoConfiguration.java b/src/main/java/reposense/model/RepoConfiguration.java index 81a895d1b4..3db17466ce 100644 --- a/src/main/java/reposense/model/RepoConfiguration.java +++ b/src/main/java/reposense/model/RepoConfiguration.java @@ -153,10 +153,6 @@ public static void setIsFindingPreviousAuthorsPerformedToRepoConfigs(List configs) { - configs.stream().forEach(config -> config.setIsFindingPreviousAuthorsPerformed(false)); - } - public static void setHasAuthorConfigFileToRepoConfigs(List configs, boolean setHasAuthorConfigFile) { configs.stream().forEach(config -> config.setHasAuthorConfigFile(setHasAuthorConfigFile)); diff --git a/src/systemtest/java/reposense/ConfigSystemTest.java b/src/systemtest/java/reposense/ConfigSystemTest.java index 6c9e9c2e10..b5fa247e40 100644 --- a/src/systemtest/java/reposense/ConfigSystemTest.java +++ b/src/systemtest/java/reposense/ConfigSystemTest.java @@ -9,13 +9,11 @@ import java.util.List; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; -import reposense.git.GitVersion; import reposense.model.SupportedDomainUrlMap; import reposense.parser.SinceDateArgumentType; import reposense.report.ErrorSummary; @@ -31,8 +29,6 @@ public class ConfigSystemTest { private static final String OUTPUT_DIRECTORY = "ft_temp"; private static final Path REPORT_DIRECTORY_PATH = Paths.get(OUTPUT_DIRECTORY, "reposense-report"); - private static final String GIT_VERSION_INSUFFICIENT_MESSAGE = "Git version 2.23.0 and above necessary to run test"; - private static boolean didNotCloneRepoNormally = true; @BeforeEach @@ -115,9 +111,6 @@ public void test30DaysFromUntilDateWithShallowCloning() { */ @Test public void testSinceBeginningDateRangeWithFindPreviousAuthors() { - Assumptions.assumeTrue(GitVersion.isGitVersionSufficientForFindingPreviousAuthors(), - GIT_VERSION_INSUFFICIENT_MESSAGE); - InputBuilder inputBuilder = initInputBuilder() .addSinceDate(SinceDateArgumentType.FIRST_COMMIT_DATE_SHORTHAND) .addUntilDate("2/3/2019") @@ -129,9 +122,6 @@ public void testSinceBeginningDateRangeWithFindPreviousAuthors() { @Test public void test30DaysFromUntilDateWithFindPreviousAuthors() { - Assumptions.assumeTrue(GitVersion.isGitVersionSufficientForFindingPreviousAuthors(), - GIT_VERSION_INSUFFICIENT_MESSAGE); - InputBuilder inputBuilder = initInputBuilder() .addUntilDate("1/11/2017") .addFindPreviousAuthors(); diff --git a/src/test/java/reposense/authorship/FileAnalyzerTest.java b/src/test/java/reposense/authorship/FileAnalyzerTest.java index f113ee0568..77c5db5819 100644 --- a/src/test/java/reposense/authorship/FileAnalyzerTest.java +++ b/src/test/java/reposense/authorship/FileAnalyzerTest.java @@ -8,14 +8,12 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import reposense.authorship.model.FileInfo; import reposense.authorship.model.FileResult; import reposense.git.GitCheckout; -import reposense.git.GitVersion; import reposense.model.Author; import reposense.model.CommitHash; import reposense.model.FileType; @@ -96,7 +94,6 @@ public void blameTest() { @Test public void blameWithPreviousAuthorsTest() { - Assumptions.assumeTrue(GitVersion.isGitVersionSufficientForFindingPreviousAuthors()); config.setSinceDate(PREVIOUS_AUTHOR_BLAME_TEST_SINCE_DATE); config.setUntilDate(PREVIOUS_AUTHOR_BLAME_TEST_UNTIL_DATE); config.setIsFindingPreviousAuthorsPerformed(true); @@ -131,7 +128,6 @@ public void blameTestDateRange() throws Exception { @Test public void blameWithPreviousAuthorsTestDateRange() throws Exception { - Assumptions.assumeTrue(GitVersion.isGitVersionSufficientForFindingPreviousAuthors()); config.setSinceDate(PREVIOUS_AUTHOR_BLAME_TEST_SINCE_DATE); config.setUntilDate(PREVIOUS_AUTHOR_BLAME_TEST_UNTIL_DATE); config.setIsFindingPreviousAuthorsPerformed(true); @@ -184,7 +180,6 @@ public void analyzeTextFile_blameTestFileIgnoreFakeAuthorCommitFullHash_success( @Test public void analyzeFile_blameWithPreviousAuthorsIgnoreFirstCommitThatChangedLine_assignLineToUnknownAuthor() { - Assumptions.assumeTrue(GitVersion.isGitVersionSufficientForFindingPreviousAuthors()); config.setSinceDate(PREVIOUS_AUTHOR_BLAME_TEST_SINCE_DATE); config.setUntilDate(PREVIOUS_AUTHOR_BLAME_TEST_UNTIL_DATE); config.setIsFindingPreviousAuthorsPerformed(true); @@ -237,7 +232,6 @@ public void analyzeTextFile_blameTestFileIgnoreAllCommit_success() { @Test public void analyzeFile_blameWithPreviousAuthorTestFileIgnoreAllCommit_success() { - Assumptions.assumeTrue(GitVersion.isGitVersionSufficientForFindingPreviousAuthors()); config.setSinceDate(PREVIOUS_AUTHOR_BLAME_TEST_SINCE_DATE); config.setUntilDate(PREVIOUS_AUTHOR_BLAME_TEST_UNTIL_DATE); config.setIsFindingPreviousAuthorsPerformed(true); diff --git a/src/test/java/reposense/git/GitBlameTest.java b/src/test/java/reposense/git/GitBlameTest.java index 2fd113279e..abb6080855 100644 --- a/src/test/java/reposense/git/GitBlameTest.java +++ b/src/test/java/reposense/git/GitBlameTest.java @@ -4,7 +4,6 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,7 +34,6 @@ public void blameRaw_nonExistentFile_throwsRunTimeException() { @Test public void blameWithPreviousAuthorsRaw_validFile_success() { - Assumptions.assumeTrue(GitVersion.isGitVersionSufficientForFindingPreviousAuthors()); config.setBranch(TEST_REPO_BLAME_WITH_PREVIOUS_AUTHORS_BRANCH); GitCheckout.checkoutBranch(config.getRepoRoot(), TEST_REPO_BLAME_WITH_PREVIOUS_AUTHORS_BRANCH); createTestIgnoreRevsFile(AUTHOR_TO_IGNORE_BLAME_COMMIT_LIST_07082021); diff --git a/src/test/java/reposense/git/GitVersionTest.java b/src/test/java/reposense/git/GitVersionTest.java deleted file mode 100644 index bd66a49613..0000000000 --- a/src/test/java/reposense/git/GitVersionTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package reposense.git; - -import static reposense.git.GitVersion.getVersionNumberAndReleaseNumberFromString; -import static reposense.git.GitVersion.isGitVersionOutputAtLeastVersion; - -import java.util.regex.Pattern; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import reposense.template.GitTestTemplate; - -public class GitVersionTest extends GitTestTemplate { - protected static final Pattern VALID_GIT_VERSION_PATTERN = Pattern.compile("git.* (\\d+.\\d+.\\d+).*"); - - @Test - public void gitVersionRaw_validGitVersion_success() { - boolean isValidGitVersion = VALID_GIT_VERSION_PATTERN.matcher(GitVersion.getGitVersion()).find(); - Assertions.assertTrue(isValidGitVersion); - } - - @Test - public void getVersionNumberAndReleaseNumberFromString_validCommandOutput_success() { - String[] expectedVersionAndReleaseNumbers1 = new String[] {"1", "0"}; - String[] expectedVersionAndReleaseNumbers2 = new String[] {"2", "22"}; - Assertions.assertArrayEquals(expectedVersionAndReleaseNumbers1, - getVersionNumberAndReleaseNumberFromString("git version 1.0.0")); - Assertions.assertArrayEquals(expectedVersionAndReleaseNumbers2, - getVersionNumberAndReleaseNumberFromString("git version 2.22.5.windows.1")); - } - - @Test - public void isGitVersionOutputAtLeastVersion_smallerThanVersions_returnsFalse() { - Assertions.assertFalse(isGitVersionOutputAtLeastVersion("git version 1.0.0", "2.23.0")); - Assertions.assertFalse(isGitVersionOutputAtLeastVersion("git version 2.17.0\n", "2.23")); - Assertions.assertFalse(isGitVersionOutputAtLeastVersion("git version 2.17.0.windows.1\n", "2.23.5")); - Assertions.assertFalse(isGitVersionOutputAtLeastVersion("git version 1.7.1", "2.0")); - } - - @Test - public void isGitVersionOutputAtLeastVersion_greaterThanVersions_returnsTrue() { - Assertions.assertTrue(isGitVersionOutputAtLeastVersion("git version 3.0.0", "2.23.0")); - Assertions.assertTrue(isGitVersionOutputAtLeastVersion("git version 2.35.0\n", "2.23")); - Assertions.assertTrue(isGitVersionOutputAtLeastVersion("git version 2.35.1.windows.2\n", "2.23.5")); - Assertions.assertTrue(isGitVersionOutputAtLeastVersion("git version 2.23.1", "2.23.1")); - } -} diff --git a/src/test/java/reposense/model/RepoConfigurationTest.java b/src/test/java/reposense/model/RepoConfigurationTest.java index 320dd64eed..0fcefbe7ff 100644 --- a/src/test/java/reposense/model/RepoConfigurationTest.java +++ b/src/test/java/reposense/model/RepoConfigurationTest.java @@ -574,9 +574,6 @@ public void repoConfig_userEnvironmentCannotRunFindPreviousAuthors_setFindPrevio RepoConfiguration.setIsFindingPreviousAuthorsPerformedToRepoConfigs(actualConfigs, cliArguments.isFindingPreviousAuthorsPerformed()); - // Assume by default that the environment does not support Find Previous Authors feature - RepoConfiguration.setToFalseIsFindingPreviousAuthorsPerformedToRepoConfigs(actualConfigs); - RepoConfiguration repoBetaActualConfig = actualConfigs.get(0); RepoConfiguration repoDeltaActualConfig = actualConfigs.get(1); TestRepoCloner.cloneAndBranch(repoBetaActualConfig);