Thank you for your interest in contributing to RepoSense!
- JDK
1.8.0_60
or later. - git
2.14
or later on the command line.
Type
git --version
on 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 Project
to 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.gradle
file and select it. ClickOK
. - Ensure that the selected version of
Gradle JVM
matches our prerequisite. - Click
OK
to 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 SUCCESSFUL
message. - Run the tests to ensure that they all pass by running the command
gradlew test systemtest
, and ensure that it finishs with aBUILD SUCCESSFUL
message.
Ensure that you are on the project root directory when using the
gradlew
commands.
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
Imports
tab to set the order
Optionally, you can follow the Using Checkstyle document to configure Intellij to check style-compliance as you write code.
Our project follows the Airbnb Javascript Style Guide, the eslint configuration file is available at the root of the project. Please run a npm run lint -- --fix frontend/src/**/*js
from the project root directory and fix all of the eslint errors before committing your code for final review.
Eslint and its accompaning modules can be installed through NPM, so do ensure that you got it installed if you are working on the dashboard.
- 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...] [-isac | --ignore-standalone-config]"
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 and automatically open the report:
gradlew run -Dargs="-config ./configs/ -output output_path/ -since 21/10/2017 -until 21/11/2017 -formats java adoc js -view"
Sample usage to generate the report with repository locations and automatically open the report:
gradlew run -Dargs="-repos https://github.com/reposense/RepoSense.git https://github.com/se-edu/collate.git -output output_path/ -since 21/10/2017 -until 21/11/2017 -formats java adoc js -view"
Sample usage to generate the report with repository locations but ignore the standalone config file:
gradlew run -Dargs="-repos https://github.com/reposense/RepoSense.git https://github.com/se-edu/collate.git --ignore-standalone-config"
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 aCliArguments
object.CsvParser
: Parses the the user-supplied CSV config file into a list ofRepoConfiguration
for each repository to analyze.
Git
package contains the wrapper classes for respective git commands.
GitBlame
: Wrapper class forgit blame
functionality. Traces the revision and author last modified each line of a file.GitBranch
: Wrapper class forgit branch
functionality. Gets the name of the working branch of the target repo.GitCheckout
: Wrapper class forgit checkout
functionality. Checks out the repository by branch name or commit hash.GitClone
: Wrapper class forgit clone
functionality. Clones the repository from GitHub into a temporary folder in order to run the analysis.GitDiff
: Wrapper class forgit diff
functionality. Obtains the changes between commits.GitLog
: Wrapper class forgit log
functionality. Obtains the commit logs and the authors' info.GitRevList
: Wrapper class forgit rev-list
functionality. Retrieves the commit objects in reverse chronological order.GitShortlog
: Wrapper class forgit shortlog
functionality. Obtains the list of authors who have contributed to the target repo.
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
CommitInfoExtractor
to run thegit log
command, which generates the statistics of each commit made within date range. - generates a
CommitInfo
for each commit, which contains theinfoLine
andstatLine
. - uses
CommitInfoAnalyzer
to extract the relevant data fromCommitInfo
into aCommitResult
, such as the number of line insertions and deletions in the commit and the author of the commit. - uses
CommitResultAggregator
to aggregate allCommitResult
into 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
FileInfoExtractor
to traverse the repository to find all relevant files. - generates a
FileInfo
for each relevant file, which contains the path to the file and a list ofLineInfo
representing each line of the file. - uses
FileInfoAnalyzer
to analyze each file, usinggit blame
or annotations, and finds theAuthor
for eachLineInfo
. - generates a
FileResult
for each file, which consolidates the authorship results into a Map of each author's line contribution to the file. - uses
FileResultAggregator
to aggregate allFileResult
into anAuthorshipSummary
.
- uses
GitDownloader
API to download the repository from GitHub. - copies the template files into the designated output directory.
- uses
CommitReporter
andAuthorshipReporter
to produce the commit and authorship summary respectively. - generates the
JSON
files needed to generate theHTML
dashboard.
System
contains the classes that interact with the Operating System and external processes.
CommandRunner
creates processes that executes commands on the terminal. It consists of many git commands.LogsManager
uses thejava.util.logging
package for logging. TheLogsManager
class is used to manage the logging levels and logging destinations. Log messages are output through:Console
and to a.log
file.DashboardServer
starts a server to display the dashboard on the browser. It depends on thenet.freeutils.httpserver
package.
Model
holds the data structures that are commonly used by the different aspects of RepoSense.
Author
stores theGitHub ID
of an author. Any contributions or commits made by the author, using his/herGitHub ID
or aliases, will be attributed to the sameAuthor
object. It is used byAuthorshipReporter
andCommitsReporter
to attribute the commit and file contributions to the respective authors.CliArguments
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 date range of commits to analyze. These configuration settings are passed intoRepoConfiguration
.RepoConfiguration
stores 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:GitDownloader
to determine which repository to download from and which branch to check out to.AuthorshipReporter
andCommitsReporter
to determine the range of commits and files to analyze.ReportGenerator
to determine the directory to output the report.
The source files for the dashboard is located in frontend/src
and is built by spuild before being packaged into the JAR file to be extracted as part of the report.
The main HTML file is generated from frontend/src/index.jade
.
Vue (pronounced /vjuː/, like view) is a progressive framework for building user interfaces. It is heavily ultilized in the dashboard to dynamically update the information in the various views. (Style guide available here).
The main Vue object (window.app
) is responsible for the loading of the dashboard (through summary.json
). Its repos
attribute is tied to the global window.REPOS
, and is passed into the various other modules when the information is needed.
window.app
is broken down into two main parts
- the summary view
- and the tabbed interface
Summary view act as the main dashboard which shows the various calculations.
Tabbed interface is responsible for loading various modules such as authorship to display additional information.
- main.js - main controller that pushes content into different modules
- api.js- loading and parsing of the dashboard content
- v_summary.js - module that supports the ramp chart view
- v_authorship.js - module that supports the authorship view
- summary.json - a list of all the repositories and their respective details
- projName/commits.json - contains information of the users' commits information (e.g. line deletion, insertion, etc), grouped by date
- projName/authorship.json - contains information from git blame, detailing the author of each line for all the processed files
This contains the logic for main VueJS object, window.app
, which is responsible for passing the necessary data into the relevant modules to be loaded.
v_summary
and v_authorship
are components which will be embedded into dashboard and will render the corresponding content based on the data passed into it from the main window.app
.
The main Vue object depends on the summary.json
data to determine the right commits.json
files to load into memory. This is handled by api.js
which loads the relevant file information from the network files if it is available, otherwise a report archive, archive.zip
, have to be used.
Once the relevant commit.json
files are loaded, all the repo information will be passed into v_summary
to be loaded in the summary view as the relevant ramp charts.
Most activity or actions should happen within the module itself, but in the case where there is a need to spawn or alter the view of another module, an event is emitted from the first module to the main Vue object (window.app
), which then handles the data received and passes it along to the relevant modules.
Other than the global main Vue object, another global variable we have is the window.hashParams
. This object is reponsible for generating the relevant permalink for a specific view of the summary module for the dashboard.
This is the module that is in charged of loading and parsing the data files generated as part of the report.
Due to security design, most modern browsers (e.g. Chrome) do not allow web pages to obtain local files using the directory alone. As such, a ZIP archive of the report information will be produced alongside the report generation.
This archive will be used in place of the network files to load information into the dashboard, in the case when the network files are unavailable.
The API module will be handling all request for all the JSON data files. If the network file is not available, the files will be obtained from the zip archive provided.
After the JSON files are loaded from their respective sources, the data will be parsed as objects and included inside the global storage object, window.REPOS
, in the right format.
For the basic skeleton of window.REPOS
, refer to the generated summary.json
file in the report for more details.
The v_summary
module is in charge of loading the ramp charts from the corresponding commits.json
.
The summary module is activated after the information is loaded from the main Vue.JS object. At creation, the repo
attribute is populated with the window.REPOS
object, which contains information loaded from summary.json
.
The commits information is retrieved from the corresponding project folders for each repository. These information will be filtered and sorted before passed into the template to be displayed as ramp charts.
For ramps between the date ranges, the slices will be selected and it will be pre and post padded with empty slices to align the ramp slice between the sinceDate
and untilDate
. The ramps will then be rendered with the slices in the right position.
The authorship module retrieves the relevant information from the corresponding authorship.json
file if it is not yet loaded. If it has been loaded, the data will be written into window.REPOS
and be read from there instead.
The files will be filtered, picking only files the selected author has written in. The lines are then split into chunks of "touched" and "untouched" code to be displayed in the tab view which will be popped up on the right side of the screen.