-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
In the author-config.csv, branch is an optional field that will automatically uses the default branch in the repo field. However, this can be improved such that if the branch field is not filled, we can bind that AuthorConfig to all the RepoConfig that has the same repo's location irregardless of branch. This can help users to easily setup config files to analyse multiple branches of a repo. Let's bind the AuthorConfig to all the RepoConfig that has the same repo's location irregardless of branch if the branch field is not filled.
- Loading branch information
Showing
8 changed files
with
71 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,8 @@ public class CsvParserTest { | |
.getResource("CsvParserTest/groupconfig_invalidLocation_test.csv").getFile()).toPath(); | ||
|
||
private static final String TEST_REPO_BETA_LOCATION = "https://github.com/reposense/testrepo-Beta.git"; | ||
private static final String TEST_REPO_BETA_BRANCH = "master"; | ||
private static final String TEST_REPO_BETA_MASTER_BRANCH = "master"; | ||
private static final String TEST_REPO_BETA_ADD_CONFIG_JSON_BRANCH = "add-config-json"; | ||
private static final List<FileType> TEST_REPO_BETA_GROUPS = Arrays.asList( | ||
new FileType("Code", Arrays.asList("**/*.java", "**/*.py")), | ||
new FileType("Docs", Collections.singletonList("docs/**"))); | ||
|
@@ -125,6 +126,7 @@ public class CsvParserTest { | |
|
||
private static final List<String> REPO_LEVEL_GLOB_LIST = Arrays.asList("collated**"); | ||
private static final List<String> FIRST_AUTHOR_GLOB_LIST = Arrays.asList("**.java", "collated**"); | ||
private static final List<String> SECOND_AUTHOR_GLOB_LIST = Arrays.asList("**.doc", "collated**"); | ||
private static final List<String> FIRST_AUTHOR_EMAIL_LIST = | ||
Arrays.asList("[email protected]", "[email protected]", "[email protected]"); | ||
|
||
|
@@ -138,7 +140,7 @@ public void repoConfig_noSpecialCharacter_success() throws IOException, InvalidL | |
RepoConfiguration config = configs.get(0); | ||
|
||
Assert.assertEquals(new RepoLocation(TEST_REPO_BETA_LOCATION), config.getLocation()); | ||
Assert.assertEquals(TEST_REPO_BETA_BRANCH, config.getBranch()); | ||
Assert.assertEquals(TEST_REPO_BETA_MASTER_BRANCH, config.getBranch()); | ||
|
||
Assert.assertEquals(TEST_REPO_BETA_CONFIG_FORMATS, config.getFileTypeManager().getFormats()); | ||
|
||
|
@@ -163,7 +165,7 @@ public void authorConfig_noSpecialCharacter_success() throws IOException, Invali | |
AuthorConfiguration config = configs.get(0); | ||
|
||
Assert.assertEquals(new RepoLocation(TEST_REPO_BETA_LOCATION), config.getLocation()); | ||
Assert.assertEquals(TEST_REPO_BETA_BRANCH, config.getBranch()); | ||
Assert.assertEquals(TEST_REPO_BETA_MASTER_BRANCH, config.getBranch()); | ||
|
||
Assert.assertEquals(AUTHOR_CONFIG_NO_SPECIAL_CHARACTER_AUTHORS, config.getAuthorList()); | ||
} | ||
|
@@ -198,7 +200,7 @@ public void authorConfig_specialCharacter_success() throws IOException, InvalidL | |
AuthorConfiguration config = configs.get(0); | ||
|
||
Assert.assertEquals(new RepoLocation(TEST_REPO_BETA_LOCATION), config.getLocation()); | ||
Assert.assertEquals(TEST_REPO_BETA_BRANCH, config.getBranch()); | ||
Assert.assertEquals(TEST_REPO_BETA_MASTER_BRANCH, config.getBranch()); | ||
|
||
Assert.assertEquals(AUTHOR_CONFIG_SPECIAL_CHARACTER_AUTHORS, config.getAuthorList()); | ||
} | ||
|
@@ -278,7 +280,7 @@ public void parse_multipleColumnsWithCommasAndDoubleQuotes_success() throws IOEx | |
AuthorConfiguration config = configs.get(0); | ||
|
||
Assert.assertEquals(new RepoLocation(TEST_REPO_BETA_LOCATION), config.getLocation()); | ||
Assert.assertEquals(TEST_REPO_BETA_BRANCH, config.getBranch()); | ||
Assert.assertEquals(TEST_REPO_BETA_MASTER_BRANCH, config.getBranch()); | ||
Assert.assertEquals(AUTHOR_DISPLAY_NAME_COMMAS_AND_DOUBLE_QUOTES_MAP, config.getAuthorDisplayNameMap()); | ||
|
||
Assert.assertEquals(AUTHOR_ALIAS_COMMAS_AND_DOUBLE_QUOTES_MAP.size(), config.getAuthorList().size()); | ||
|
@@ -290,20 +292,27 @@ public void parse_multipleColumnsWithCommasAndDoubleQuotes_success() throws IOEx | |
@Test | ||
public void merge_twoRepoConfigs_success() throws ParseException, IOException, HelpScreenException { | ||
FIRST_AUTHOR.setIgnoreGlobList(FIRST_AUTHOR_GLOB_LIST); | ||
SECOND_AUTHOR.setIgnoreGlobList(REPO_LEVEL_GLOB_LIST); | ||
SECOND_AUTHOR.setIgnoreGlobList(SECOND_AUTHOR_GLOB_LIST); | ||
SECOND_AUTHOR.setAuthorAliases(SECOND_AUTHOR_ALIASES); | ||
|
||
List<Author> expectedAuthors = new ArrayList<>(); | ||
expectedAuthors.add(FIRST_AUTHOR); | ||
expectedAuthors.add(SECOND_AUTHOR); | ||
|
||
RepoConfiguration expectedConfig = new RepoConfiguration(new RepoLocation(TEST_REPO_BETA_LOCATION), | ||
TEST_REPO_BETA_BRANCH); | ||
expectedConfig.setAuthorList(expectedAuthors); | ||
expectedConfig.setAuthorDisplayName(FIRST_AUTHOR, "Nbr"); | ||
expectedConfig.setAuthorDisplayName(SECOND_AUTHOR, "Zac"); | ||
expectedConfig.addAuthorEmailsAndAliasesMapEntry(SECOND_AUTHOR, Arrays.asList("Zachary Tang")); | ||
expectedConfig.setIgnoreGlobList(REPO_LEVEL_GLOB_LIST); | ||
RepoConfiguration firstRepo = new RepoConfiguration(new RepoLocation(TEST_REPO_BETA_LOCATION), | ||
TEST_REPO_BETA_MASTER_BRANCH); | ||
firstRepo.setAuthorList(expectedAuthors); | ||
firstRepo.setAuthorDisplayName(FIRST_AUTHOR, "Nbr"); | ||
firstRepo.setAuthorDisplayName(SECOND_AUTHOR, "Zac"); | ||
firstRepo.addAuthorEmailsAndAliasesMapEntry(SECOND_AUTHOR, Arrays.asList("Zachary Tang")); | ||
firstRepo.setIgnoreGlobList(REPO_LEVEL_GLOB_LIST); | ||
|
||
RepoConfiguration secondRepo = new RepoConfiguration(new RepoLocation(TEST_REPO_BETA_LOCATION), | ||
TEST_REPO_BETA_ADD_CONFIG_JSON_BRANCH); | ||
secondRepo.setAuthorList(Arrays.asList(SECOND_AUTHOR)); | ||
secondRepo.setAuthorDisplayName(SECOND_AUTHOR, "Zac"); | ||
secondRepo.addAuthorEmailsAndAliasesMapEntry(SECOND_AUTHOR, Arrays.asList("Zachary Tang")); | ||
secondRepo.setIgnoreGlobList(REPO_LEVEL_GLOB_LIST); | ||
|
||
String input = new InputBuilder().addConfig(TEST_CONFIG_FOLDER).build(); | ||
CliArguments cliArguments = ArgsParser.parse(translateCommandline(input)); | ||
|
@@ -314,8 +323,9 @@ public void merge_twoRepoConfigs_success() throws ParseException, IOException, H | |
new AuthorConfigCsvParser(((ConfigCliArguments) cliArguments).getAuthorConfigFilePath()).parse(); | ||
RepoConfiguration.merge(actualConfigs, authorConfigs); | ||
|
||
Assert.assertEquals(1, actualConfigs.size()); | ||
TestUtil.compareRepoConfig(expectedConfig, actualConfigs.get(0)); | ||
Assert.assertEquals(2, actualConfigs.size()); | ||
TestUtil.compareRepoConfig(firstRepo, actualConfigs.get(0)); | ||
TestUtil.compareRepoConfig(secondRepo, actualConfigs.get(1)); | ||
} | ||
|
||
@Test | ||
|
@@ -325,14 +335,14 @@ public void merge_emptyLocation_success() throws ParseException, IOException, He | |
SECOND_AUTHOR.setAuthorAliases(SECOND_AUTHOR_ALIASES); | ||
|
||
List<Author> expectedBetaAuthors = new ArrayList<>(); | ||
expectedBetaAuthors.add(SECOND_AUTHOR); | ||
expectedBetaAuthors.add(FIRST_AUTHOR); | ||
expectedBetaAuthors.add(SECOND_AUTHOR); | ||
|
||
List<Author> expectedDeltaAuthors = new ArrayList<>(); | ||
expectedDeltaAuthors.add(FIRST_AUTHOR); | ||
|
||
RepoConfiguration expectedBetaConfig = | ||
new RepoConfiguration(new RepoLocation(TEST_REPO_BETA_LOCATION), TEST_REPO_BETA_BRANCH); | ||
new RepoConfiguration(new RepoLocation(TEST_REPO_BETA_LOCATION), TEST_REPO_BETA_MASTER_BRANCH); | ||
expectedBetaConfig.setAuthorList(expectedBetaAuthors); | ||
expectedBetaConfig.setAuthorDisplayName(FIRST_AUTHOR, "Nbr"); | ||
expectedBetaConfig.setAuthorDisplayName(SECOND_AUTHOR, "Zac"); | ||
|
@@ -393,7 +403,7 @@ public void repoConfig_overrideKeyword_success() throws ParseException, IOExcept | |
|
||
Assert.assertEquals(1, configs.size()); | ||
Assert.assertEquals(new RepoLocation(TEST_REPO_BETA_LOCATION), config.getLocation()); | ||
Assert.assertEquals(TEST_REPO_BETA_BRANCH, config.getBranch()); | ||
Assert.assertEquals(TEST_REPO_BETA_MASTER_BRANCH, config.getBranch()); | ||
Assert.assertEquals(TEST_REPO_BETA_CONFIG_FORMATS, config.getFileTypeManager().getFormats()); | ||
Assert.assertFalse(config.isStandaloneConfigIgnored()); | ||
Assert.assertEquals(CommitHash.convertStringsToCommits(TEST_REPO_BETA_CONFIG_IGNORED_COMMITS), | ||
|
@@ -415,7 +425,7 @@ public void repoConfig_redundantLines_success() throws ParseException, IOExcepti | |
RepoConfiguration deltaConfig = configs.get(2); | ||
|
||
Assert.assertEquals(new RepoLocation(TEST_REPO_BETA_LOCATION), betaConfig.getLocation()); | ||
Assert.assertEquals(TEST_REPO_BETA_BRANCH, betaConfig.getBranch()); | ||
Assert.assertEquals(TEST_REPO_BETA_MASTER_BRANCH, betaConfig.getBranch()); | ||
Assert.assertEquals(new RepoLocation(TEST_REPO_CHARLIE_LOCATION), charlieConfig.getLocation()); | ||
Assert.assertEquals(TEST_REPO_CHARLIE_BRANCH, charlieConfig.getBranch()); | ||
Assert.assertEquals(new RepoLocation(TEST_REPO_DELTA_LOCATION), deltaConfig.getLocation()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Repository's Location,Branch,Author's GitHub ID,Author's Email,Author's Display Name,Author's Git Author Name,Ignore Glob List | ||
https://github.com/reposense/testrepo-Beta.git,master,nbriannl,,Nbr,,**.java | ||
https://github.com/reposense/testrepo-Beta.git,master,zacharytang,,Zac,Zachary Tang, | ||
https://github.com/reposense/testrepo-Beta.git,,zacharytang,,Zac,Zachary Tang,**.doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Repository's Location,Branch,File formats,Ignore Glob List,Ignore standalone config,Ignore Commits List | ||
https://github.com/reposense/testrepo-Beta.git,master,,collated**,, | ||
https://github.com/reposense/testrepo-Beta.git,add-config-json,,collated**,, |