Thank you for your interest in contributing to RepoSense!
- JDK
1.8.0_60or later. - git
2.14or later on the command line.
Type
git --versionon your OS terminal and ensure that you have the correct version of git.
- Fork this repo, and clone the fork to your computer.
- Open IntelliJ (if you are not in the welcome screen, click
File>Close Projectto close the existing project dialog first). - Set up the correct JDK version for Gradle.
- Click
Configure>Project Defaults>Project Structure. - Click
New…and find the directory of the JDK.
- Click
- Click
Import Project. - Locate the
build.gradlefile and select it. ClickOK. - Ensure that the selected version of
Gradle JVMmatches our prerequisite. - Click
OKto accept the all the other default settings.
- Ensure that Gradle builds without error by running the command
gradlew clean build, and ensure that it finishs with aBUILD SUCCESSFULmessage. - Run the tests to ensure that they all pass by running the command
gradlew test functional, and ensure that it finishs with aBUILD SUCCESSFULmessage.
Ensure that you are on the project root directory when using the
gradlewcommands.
This project follows oss-generic coding standards. IntelliJ’s default style is mostly compliant with our Java coding convention but it uses a different import order from ours. To rectify,
- Go to
File>Settings… (Windows/Linux), orIntelliJ IDEA>Preferences… (macOS). - Select
Editor>Code Style>Java. - Click on the
Importstab to set the order
Optionally, you can follow the Using Checkstyle document to configure Intellij to check style-compliance as you write code.
- Do check out our process guide before submitting any PR with your changes.
- Execute the following command on the OS terminal inside the project directory.
Usage:gradlew run -Dargs="([-config CONFIG_FOLDER] | -repos REPO_PATH_OR_URL... | -view REPORT_FOLDER) [-output OUTPUT_DIRECTORY] [-since DD/MM/YYYY] [-until DD/MM/YYYY] [-formats FORMAT...]"
Sample usage to generate the report with no specify arguments: (find and use config files in current working directory)
gradlew run
Sample usage to generate the report with config files:
gradlew run -Dargs="-config ./configs/ -output output_path/ -since 01/10/2017 -until 01/11/2017 -formats java adoc js"
Sample usage to generate the report with repository locations:
gradlew run -Dargs="-repos https://github.com/reposense/RepoSense.git https://github.com/se-edu/collate.git -output output_path/ -since 01/10/2017 -until 01/11/2017 -formats java adoc js"
Sample usage to view the report:
gradlew run -Dargs="-view output_path/reposense-report"
-Dargs="..." uses the same argument format as mentioned above.
Figure 1. Overall architecture of RepoSense
Parser contains two classes:
ArgsParser: Parses the user-supplied command line arguments into aCliArgumentsobject.CsvParser: Parses the the user-supplied CSV config file into a list ofRepoConfigurationfor each repository to analyze.
Git contains the wrapper classes for respective git commands.
GitDownloader: Wrapper class forgit clonefunctionality. Clones the repository from GitHub into a temporary folder in order to run the analysis.GitChecker: Wrapper class forgit checkoutfunctionality. Checks out the repository by branch name or commit hash.
CommitsReporter is responsible for analyzing the commit history and generating a CommitContributionSummary for each repository. CommitContributionSummary contains information such as each author's daily and weekly contribution and the variance of their contribution. CommitsReporter,
- uses
CommitInfoExtractorto run thegit logcommand, which generates the statistics of each commit made within date range. - generates a
CommitInfofor each commit, which contains theinfoLineandstatLine. - uses
CommitInfoAnalyzerto extract the relevant data fromCommitInfointo aCommitResult, such as the number of line insertions and deletions in the commit and the author of the commit. - uses
CommitResultAggregatorto aggregate allCommitResultinto aCommitContributionSummary.
AuthorshipReporter is responsible for analyzing the white listed files, traces the original author for each line of text/code, and generating an AuthorshipSummary for each repository. AuthorshipSummary contains the analysis results of the white listed files and the amount of line contributions each author made. AuthorshipReporter,
- uses
FileInfoExtractorto traverse the repository to find all relevant files. - generates a
FileInfofor each relevant file, which contains the path to the file and a list ofLineInforepresenting each line of the file. - uses
FileInfoAnalyzerto analyze each file, usinggit blameor annotations, and finds theAuthorfor eachLineInfo. - generates a
FileResultfor each file, which consolidates the authorship results into a Map of each author's line contribution to the file. - uses
FileResultAggregatorto aggregate allFileResultinto anAuthorshipSummary.
- uses
GitDownloaderAPI to download the repository from GitHub. - copies the template files into the designated output directory.
- uses
CommitReporterandAuthorshipReporterto produce the commit and authorship summary respectively. - generates the
JSONfiles needed to generate theHTMLdashboard.
System contains the classes that interact with the Operating System and external processes.
CommandRunnercreates processes that executes commands on the terminal. It consists of many git commands.LogsManageruses thejava.util.loggingpackage for logging. TheLogsManagerclass is used to manage the logging levels and logging destinations. Log messages are output through:Consoleand to a.logfile.DashboardServerstarts a server to display the dashboard on the browser. It depends on thenet.freeutils.httpserverpackage.
Model holds the data structures that are commonly used by the different aspects of RepoSense.
Authorstores theGitHub IDof an author. Any contributions or commits made by the author, using his/herGitHub IDor aliases, will be attributed to the sameAuthorobject. It is used byAuthorshipReporterandCommitsReporterto attribute the commit and file contributions to the respective authors.CliArgumentsstores 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 date range of commits to analyze. These configuration settings are passed intoRepoConfiguration.RepoConfigurationstores the configuration information from the CSV config file for a single repository, which are the repository's orgarization, name, branch, list of authors to analyse, date range to analyze commits and files fromCliArguments. These configuration information are used by:GitDownloaderto determine which repository to download from and which branch to check out to.AuthorshipReporterandCommitsReporterto determine the range of commits and files to analyze.ReportGeneratorto determine the directory to output the report.
The dashboard contains two main parts: data JSONs(generated by ReportGenerator), and the static Dashboard template. Refer to here for instructions on how to build the project and dashboard.
-
As shown in the graph above, there will be one summary
JSON(summary.json) containing the summary information of all repositories, and one set of repo detailJSON(commits.jsonandauthorship.json) for each repository, containing the contribution information of each specified author to that repository. -
The dashboard template is a set of
HTML+CSS+Javascript, which is located intemplate/. It is used to interpret theJSONinformation and display the dashboard on a web browser.
Whenever RepoSense is built using Gradle, the current dashboard template's content will be zipped intotemplateZip.zipfile for easier retrieval, and packaging into the generated.jarfile.
The dashboard template will then be unzipped to the target location along with the generatedJSONdata files in order to produce the dashboard whenever RepoSense generates a new report.

