Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1726] Update GitHub-specific references in codebase and docs #2050

Merged
merged 10 commits into from
Nov 8, 2023
4 changes: 2 additions & 2 deletions docs/dg/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* [`GitBranch`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitBranch.java): Wrapper class for `git branch` functionality. Gets the name of the working branch of the target repo.
* [`GitCatFile`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitCatFile.java): Wrapper class for `git cat-file` functionality. Obtains the parent commit hash with the given commit indicated by the commit hash.
* [`GitCheckout`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitCheckout.java): Wrapper class for `git checkout` functionality. Checks out the repository by branch name or commit hash.
* [`GitClone`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitClone.java): Wrapper class for `git clone` functionality. Clones the repository from *GitHub* into a temporary folder in order to run the analysis.
* [`GitClone`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitClone.java): Wrapper class for `git clone` functionality. Clones the repository from the given URL or local directory into a temporary folder in order to run the analysis.
* [`GitDiff`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitDiff.java): Wrapper class for `git diff` functionality. Obtains the changes between commits.
* [`GitLog`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitLog.java): Wrapper class for `git log` functionality. Obtains the commit logs and the authors' info.
* [`GitRevList`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/git/GitRevList.java): Wrapper class for `git rev-list` functionality. Retrieves the commit objects in reverse chronological order.
Expand Down Expand Up @@ -93,7 +93,7 @@ Note that when constructing new commands containing path arguments, use the `Str
## Model

[`Model`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/model) holds the data structures that are commonly used by the different aspects of *RepoSense*.
* [`Author`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/model/Author.java) stores the `GitHub ID` of an author. Any contributions or commits made by the author, using his/her `GitHub ID` or aliases, will be attributed to the same `Author` object. `AuthorshipReporter` and `CommitsReporter` use it to attribute the commit and file contributions to the respective authors.
* [`Author`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/model/Author.java) stores the `Git ID` of an author. Any contributions or commits made by the author, using his/her `Git ID` or aliases, will be attributed to the same `Author` object. `AuthorshipReporter` and `CommitsReporter` use it to attribute the commit and file contributions to the respective authors.
* [`CliArguments`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/model/CliArguments.java) stores the parsed command-line arguments supplied by the user. It contains the configuration settings such as the CSV config file to read from, the directory to output the report to, and the date range of commits to analyze. These configuration settings are passed into `RepoConfiguration`.
* [`FileTypeManager`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/model/FileTypeManager.java) stores the file format to be analyzed and the custom groups specified by the user for any repository.
* [`RepoConfiguration`](https://github.com/reposense/RepoSense/blob/master/src/main/java/reposense/model/RepoConfiguration.java) stores the configuration information from the CSV config file for a single repository: the repository's organization, name, branch, list of authors to analyze, date range to analyze commits, and files from `CliArguments`.
Expand Down
8 changes: 4 additions & 4 deletions docs/ug/configFiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ To use this feature, add a `_reposense/config.json` to the root of your repo usi
"authors":
[
{
"githubId": "alice",
"gitId": "alice",
"emails": ["[email protected]", "[email protected]"],
"displayName": "Alice T.",
"authorNames": ["AT", "A"],
"ignoreGlobList": ["**.css"]
},
{
"githubId": "bob"
"gitId": "bob"
}
]
}
Expand All @@ -159,10 +159,10 @@ Note: all fields are optional unless specified otherwise.

**Fields to provide _author-level_ info**:<br>
Note: `authors` field should contain _all_ authors that should be captured in the analysis.
* `githubId`: Username of the author. {{ mandatory }} field.
* `gitId`: Username of the author. {{ mandatory }} field.
* `emails`: Associated git emails of the author. For GitHub, this can be found in your [GitHub settings](https://github.com/settings/emails).
* `displayName`: Name to display on the report for this author.
* `authorNames`: Git Author Name(s) used in the author's commits. By default, RepoSense assumes an author would use her GitHub username as the Git username too. The meaning of _Git Author Name_ is explained in [_A note about git author name_](#a-note-about-git-author-name).
* `authorNames`: Git Author Name(s) used in the author's commits. By default, RepoSense assumes an author would use their remote Git Host username as the Git username too. The meaning of _Git Author Name_ is explained in [_A note about git author name_](#a-note-about-git-author-name).
* `ignoreGlobList`: _Additional_ (i.e. on top of the repo-level `ignoreGlobList`) folders/files to ignore for a specific author. The path glob syntax is specified by the [_glob format_](https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob). In the example above, the actual `ignoreGlobList` for `alice` would be `["about-us/**", "**index.html", "**.css"]`.

To verify your standalone configuration is as intended, add the `_reposense/config.json` to your local copy of repo and run RepoSense against it as follows:<br>
Expand Down
4 changes: 2 additions & 2 deletions docs/ug/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

### Contributions missing in the ramp chart (but appear in the contribution bar and code panel)

This is probably a case of giving an incorrect author name alias (or GitHub ID) in your [author-config file](./configFiles.md#author-config-csv).<br>
This is probably a case of giving an incorrect author name alias (or Git ID) in your [author-config file](./configFiles.md#author-config-csv).<br>
Please refer to [A Note About Git Author Name](./configFiles.md#a-note-about-git-author-name) above on how to find out the correct author name you are using and how to change it.<br>
Also, ensure that you have added all author name aliases you may be using (if you are using multiple computers or have previously changed your author name).<br>
Alternatively, you may choose to configure *RepoSense* to track using your GitHub email instead of in your [standalone config file](./configFiles.md#config-json-standalone-config-file) or [author-config file](./configFiles.md#author-config-csv), which is more accurate compared to author name aliases. The associated GitHub email you are using can be found in your [GitHub settings](https://github.com/settings/emails).
Alternatively, you may choose to configure *RepoSense* to track the email associated with your local Git config or remote Git host email in a [standalone config file](./configFiles.md#config-json-standalone-config-file) or [author-config file](./configFiles.md#author-config-csv), which is more accurate compared to author name aliases. For GitHub, the associated email you are using can be found in your [GitHub settings](https://github.com/settings/emails).


<!-- ------------------------------------------------------------------------------------------------------ -->
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/reposense/model/Author.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class Author {
public static final String NAME_NO_AUTHOR_WITH_COMMITS_FOUND =
"NO AUTHOR WITH COMMITS FOUND WITHIN THIS PERIOD OF TIME";
private static final String UNKNOWN_AUTHOR_GIT_ID = "-";

private static final String STANDARD_GITHUB_EMAIL_DOMAIN = "@users.noreply.github.com";
private static final String STANDARD_GITLAB_EMAIL_DOMAIN = "@users.noreply.gitlab.com";

private static final String MESSAGE_UNCOMMON_EMAIL_PATTERN = "The provided email, %s, uses uncommon pattern.";
private static final String MESSAGE_UNCOMMON_GLOB_PATTERN = "The provided ignore glob, %s, uses uncommon pattern.";
private static final String COMMON_EMAIL_REGEX =
Expand All @@ -37,14 +40,14 @@ public Author(String gitId) {
this.authorAliases = new ArrayList<>();
this.ignoreGlobList = new ArrayList<>();

addStandardGitHubEmail(this.emails);
addStandardGitHostEmails(this.emails);
updateIgnoreGlobMatcher();
}

public Author(StandaloneAuthor sa) {
String gitId = sa.getGithubId();
String gitId = sa.getGitId();
List<String> emails = new ArrayList<>(sa.getEmails());
String displayName = !sa.getDisplayName().isEmpty() ? sa.getDisplayName() : sa.getGithubId();
String displayName = !sa.getDisplayName().isEmpty() ? sa.getDisplayName() : sa.getGitId();
List<String> authorAliases = sa.getAuthorNames();
List<String> ignoreGlobList = sa.getIgnoreGlobList();

Expand Down Expand Up @@ -102,7 +105,7 @@ public List<String> getEmails() {
public void setEmails(List<String> emails) {
validateEmails(emails);
this.emails = new ArrayList<>(emails);
addStandardGitHubEmail(this.emails);
addStandardGitHostEmails(this.emails);
}

public String getDisplayName() {
Expand Down Expand Up @@ -188,13 +191,17 @@ private void updateIgnoreGlobMatcher() {
}

/**
* Adds the standard github email to {@code emails} if doesn't exist.
* Adds the standard github and gitlab emails to {@code emails} if not present.
*/
private void addStandardGitHubEmail(List<String> emails) {
private void addStandardGitHostEmails(List<String> emails) {
String standardGitHubEmail = getGitId() + STANDARD_GITHUB_EMAIL_DOMAIN;
String standardGitLabEmail = getGitId() + STANDARD_GITLAB_EMAIL_DOMAIN;
if (!emails.contains(standardGitHubEmail)) {
emails.add(standardGitHubEmail);
}
if (!emails.contains(standardGitLabEmail)) {
emails.add(standardGitLabEmail);
}
}
}

2 changes: 1 addition & 1 deletion src/main/java/reposense/model/AuthorConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public List<Author> getAuthorList() {
* and display name.
*/
private void setAuthorDetails(Author author) {
// Set GitHub Id and its corresponding email as default
// Set Git Id and its corresponding email as default
addAuthorNamesToAuthorMapEntry(author, author.getGitId());
addAuthorNamesToAuthorMapEntry(author, author.getAuthorAliases());

Expand Down
13 changes: 10 additions & 3 deletions src/main/java/reposense/model/StandaloneAuthor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

import java.util.Collections;
import java.util.List;
import java.util.Optional;

/**
* Represents an author in {@link StandaloneConfig}.
*/
public class StandaloneAuthor {

private String gitId;
// This is for backward compatibility with older standalone author configs that utilize the 'githubId' keyword.
private String githubId;

private List<String> emails;
private String displayName;
private List<String> authorNames;
private List<String> ignoreGlobList;

public String getGithubId() {
return githubId;
public String getGitId() {
// This supports a standalone json file containing either keywords, prioritizing 'gitId'.
// To remove backward compatibility support, need to update the standalone json configs in test repositories.
return Optional.ofNullable(gitId).orElse(githubId);
}

public List<String> getEmails() {
Expand Down Expand Up @@ -44,7 +51,7 @@ public boolean equals(Object other) {
}

StandaloneAuthor otherStandaloneAuthor = (StandaloneAuthor) other;
return githubId.equals(otherStandaloneAuthor.githubId)
return gitId.equals(otherStandaloneAuthor.gitId)
&& getEmails().equals(otherStandaloneAuthor.getEmails())
&& getDisplayName().equals(otherStandaloneAuthor.getDisplayName())
&& getAuthorNames().equals(otherStandaloneAuthor.getAuthorNames())
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reposense/parser/ArgsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private static ArgumentParser getArgumentParser() {
.nargs("+")
.dest(REPO_FLAGS[0])
.metavar("LOCATION")
.help("The GitHub URL or disk locations to clone repository.");
.help("The remote Git host URLs or local directories to clone the repositories from.");

mutexParser2.addArgument(LAST_MODIFIED_DATE_FLAGS)
.dest(LAST_MODIFIED_DATE_FLAGS[0])
Expand Down
27 changes: 19 additions & 8 deletions src/test/java/reposense/model/AuthorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@ public class AuthorTest {

@Test
public void setEmail_validEmails_success() {
Author author = new Author("Tester");
String[] emails = new String[] {"[email protected]", "[email protected]"};

author.setEmails(Arrays.asList(emails));
List<String> emails = new ArrayList<>();
emails.add("[email protected]");
emails.add("[email protected]");

// The additional 1 email comes from the Standard GitHub Email.
Assertions.assertEquals(emails.length + 1, author.getEmails().size());

Assertions.assertTrue(author.getEmails().containsAll(Arrays.asList(emails)));
Author author = new Author("Tester");
author.setEmails(emails);
// The additional 2 emails comes from the Standard GitHub & Gitlab Emails.
Assertions.assertEquals(emails.size() + 2, author.getEmails().size());
Assertions.assertTrue(author.getEmails().containsAll(emails));

emails.add("[email protected]");
author.setEmails(emails);
// The additional 1 email comes from the Gitlab email as the standard GitHub has already been included.
Assertions.assertEquals(emails.size() + 1, author.getEmails().size());
Assertions.assertTrue(author.getEmails().containsAll(emails));

emails.add("[email protected]");
author.setEmails(emails);
Assertions.assertEquals(emails.size(), author.getEmails().size());
Assertions.assertTrue(author.getEmails().containsAll(emails));
}

@Test
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/reposense/parser/AuthorConfigParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public class AuthorConfigParserTest {
.collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue()));

private static final List<String> FIRST_AUTHOR_EMAIL_LIST =
Arrays.asList("[email protected]", "[email protected]", "[email protected]");
Arrays.asList("[email protected]", "[email protected]", "[email protected]",
"[email protected]");

@Test
public void authorConfig_noSpecialCharacter_success() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"authors":
[
{
"githubId": "yong24s",
"gitId": "yong24s",
"displayName": "Yong Hao",
"authorNames": ["Yong Hao TENG"],
"ignoreGlobList": ["**.css", "**.html", "**.jade", "**.js"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"authors":
[
{
"githubId": "yong24s"
"gitId": "yong24s"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"authors":
[
{
"githubId": "yong24s"
"gitId": "yong24s"
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"authors":
[
{
"githubId": "yong24s",
"gitId": "yong24s",
"level": "1"
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"authors":
[
{
"githubId": "lithiumlkid",
"gitId": "lithiumlkid",
"displayName": "Ahm",
"authorNames": ["Ahmad Syafiq"],
"ignoreGlobList": ["*.aa1", "**.aa2", "**.java"]
},
{
"githubId": "codeeong",
"gitId": "codeeong",
"displayName": "Cod",
"authorNames": ["Codee"],
"ignoreGlobList": ["**[!(.md)]"]
},
{
"githubId": "jordancjq",
"gitId": "jordancjq",
"displayName": "Jor",
"authorNames": ["Jordan Chong"],
"ignoreGlobList": [""]
},
{
"githubId": "lohtianwei",
"gitId": "lohtianwei",
"displayName": "Loh",
"authorNames": ["Tianwei"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
"authors":
[
{
"githubId": "lithiumlkid",
"gitId": "lithiumlkid",
"displayName": "Ahm",
"authorNames": ["Ahmad Syafiq"],
"ignoreGlobList": ["*.aa1", "**.aa2", "**.java"]
},
{
"githubId": "codeeong",
"gitId": "codeeong",
"displayName": "Cod",
"authorNames": ["Codee"],
"ignoreGlobList": ["**[!(.md)]"]
},
{
"githubId": "jordancjq",
"gitId": "jordancjq",
"displayName": "Jor",
"authorNames": ["Jordan Chong"],
"ignoreGlobList": [""]
},
{
"githubId": "lohtianwei",
"gitId": "lohtianwei",
"displayName": "Loh",
"authorNames": ["Tianwei"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"authors":
[
{
"githubId": "lithiumlkid",
"gitId": "lithiumlkid",
"displayName": "Ahm",
"authorNames": ["Ahmad Syafiq"],
"ignoreGlobList": ["*.aa1", "**.aa2", "**.java"]
},
{
"githubId": "codeeong",
"gitId": "codeeong",
"displayName": "Cod",
"authorNames": ["Codee"],
"ignoreGlobList": ["**[!(.md)]"]
},
{
"githubId": "jordancjq",
"gitId": "jordancjq",
"displayName": "Jor",
"authorNames": ["Jordan Chong"],
"ignoreGlobList": [""]
},
{
"githubId": "lohtianwei",
"gitId": "lohtianwei",
"displayName": "Loh",
"authorNames": ["Tianwei"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"authors":
[
{
"githubId": "lithiumlkid",
"gitId": "lithiumlkid",
"displayName": "Ahm",
"authorNames": ["Ahmad Syafiq"],
"ignoreGlobList": ["*.aa1", "**.aa2", "**.java"]
},
{
"githubId": "codeeong",
"gitId": "codeeong",
"displayName": "Cod",
"authorNames": ["Codee"],
"ignoreGlobList": ["**[!(.md)]"]
},
{
"githubId": "jordancjq",
"gitId": "jordancjq",
"displayName": "Jor",
"authorNames": ["Jordan Chong"],
"ignoreGlobList": [""]
},
{
"githubId": "lohtianwei",
"gitId": "lohtianwei",
"displayName": "Loh",
"authorNames": ["Tianwei"]
}
Expand Down
Loading
Loading