Software Integration
Version control systems (VCSs), which keep track of the software development history, have become an essential component of modern software development. With the increase of distributed software development, additional coordination tools and processes to facilitate collaboration between team members who may be working on different tasks have been introduced. For example, large software systems commonly make use of branching in distributed version control systems. Developers typically follow a branch-based development approach, where new features or bug fixes are developed in separate branches before being integrated into the master branch, or another stable branch
While branching (or forking where the developer may make a tracked copy of the work in a separate repository has several advantages such as allowing better separation of concerns and enabling parallel development , it still comes at the cost of integration challenges. Once a developer has completed the intended work in a given branch, they need to merge their changes with the rest of the team’s work. At this point, merge conflicts may arise, because of inconsistent changes to the code. Previous studies have shown that up to 16% of merge scenarios lead to conflicts. Developers have to resolve such conflicts before proceeding, which wastes their time and distracts them from their main tasks.
Materials & Tools Used for this Session
- Lecture sides here
- IntelliJ IDE (you can use Eclipse at your discretion, but it may require some adaptations for the project we are using during the lab sessions)
- RefactoringsInMergeCommits
- Refactoring-Aware Merging
Setup / Preparation
In this lab you will play with two very related tools: Refactorings in Merge Commits and Refactoring-Aware Merging
Task 1 - Refactorings in Merge Commits
In this task you will try to understand how Refactorings in Merge Commits analyzes merge commits in git repositries and determines whether refactoring changes are to blame for the conflicts.
Prepare the tool environment according to the system requirements of the tool located on the README.md file.
You may also follow the instructions below that are adapted from README.md.
System Requirements
- Linux or macOS
- git
- Java 11. If you have more than one Java version on your machine, you can run this command on the terminal inside Intellij
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home
- MySQL 5.7 (Install this version of mysql). Create a
USERNAME
andPASSWORD
, they are needed in the next step. - I would recommend installing phpMyAdmin to help with running SQL queries. You can install it using brew install –cask xampp (if you have a Mac OS)
Running the JAR file
- You need to start MySql server. You can do this by starting
xammp
(if you are using a Mac OS, just go to the xampp application (folder) and double-click the filemanager-osx
) - When mysql server is up and running, type this in the browser to confirm that everything is working fine
http://localhost/phpmyadmin/index.php
- Clone-and-own RefactoringsInMergeCommits and then open the project in IntelliJ IDE.
- Edit the
database.properties
file and replace theUSERNAME
andPASSWORD
with the ones you created formysql
earlier.
development.driver=com.mysql.jdbc.Driver
development.username=USERNAME -> replace
development.password=PASSWORD -> replace
development.url=jdbc:mysql://localhost/refactoring_analysis
-
If you wish, you can choose a different name for the database (
refactoring_analysis
in the template) -
Open the terminal in
IntelliJ IDE
run the commands below:
./mvnw clean activejdbc-instrumentation:instrument compile assembly:single clean
java -jar refactoring-analysis.jar
(You may have to run the commands sudo unlink /etc/localtime
and ln -sf /usr/share/zoneinfo/UTC /etc/localtime
to change the timezone to the local time. More info about timezone here))
Download the like repList.txt and replace it with of the default reposList.txt in the cloned project RefactoringsInMergeCommits
Generate stat summaries After the program has finished running, you can use the Python scripts in the stats folder to look at the results.
- data_resolver.py: This script will print a summary of stats, including total number of merge scenarios, merge scenarios with involved refacotirngs, conflicting regions with involved refactorings, etc.
- plotter.py: This script can draw a number of different plots.
Task 1.2
Scan through the code and understand how these different refactoring aware operations are implemented:
- Detecting conflicting regions
- Detecting evolutionary changes
- Detecting refactorings (notice that only a few refactoring operations have been implemented this tool. In the Project, you will be required to extend this tool with more refactoring operations)
- Detecting refactorings in the conflicting region
The above steps are explained in detail in Section 3: Methodology of the paper Are Refactorings to Blame? An Empirical Study of Refactorings in Merge Conflicts. Of course reading the whole paper would be ideal, but reading only Section 3 should be sufficient.
You could also export the sql structure from the database and reverse engineer the ER diagram using MySql Workbench to Understand how the different tables are interconnected
Task 1.2 - Optional
Looking at the tool Refactorings in Merge Commits we can see that only a subset of the refactoring operations mentioned in the Readme.md of tool RefactoringMiner have been implemented. Extend Refactorings in Merge Commits with a set of more refactoring operations. Write and run tests to ensure that they have been well implemented.
Note: RefactoringsInMergeCommits implements refactoring operations of RefactoringMiner version 2.1.0. Some on the new refactorings are only present in later versions of the tool.
You may find the following links interesting that will help you in the project:
git log
. In the Project we shall be mining data for analysis from thegit log
. Therefore, it is very important to understand how they are implementedgit log
these two projects: Refactorings in Merge Commits and Refactoring-Aware Merging. Please read the code in depthgit cherry-pick
or in general the git documentation
RefactoringsInMergeCommits implements git merge, but in the Project the command git merge will be replaced with git cherry-pick
Task 2 (Optional)
Scan through the code and understand how the following refactoring-aware operations are implemented (First Contact - Readall the Code in One Hour OORP, p.53).
- Detect and Simplify Refactorings
- Invert refactorings
- Merge
- Detect Refactoring Conflicts
- Replay Refactorings
The above steps are described in detail in the paper: Section 3 - REFMERGE: REFACTORING-AWARE OPERATION BASED MERGING of the paper A Systematic Comparison of Two Refactoring-aware Merging Techniques
Task 2.1 - Optional
Refactoring-Aware Merging is a robust project comprising of two tools RefMerge and an Evaluation tool.
We are only interested RefMerge that performs refactoring-aware merging operations.
Refactoring-Aware Merging will be used in the final project, take time to understand how it is implemented.
How to run
Follow the instruction on the Readme.md file of the project to build and run the project.
You may also use the following steps that were adapted from the Readme.md file of RefMerge and Readme.md file of RefactoringMiner
- Clone and build
RefactoringMiner
Use git clone https://github.com/tsantalis/RefactoringMiner.git to clone RefactoringMiner. Then build RefactoringMiner with./gradlew distzip
. It will be under build/distributions. -
In order to use RefactoringMiner as a maven dependency in your project, you will need to add RefactoringMiner to your local maven repository
- Add the following snippet to your project’s build configuration file:
<dependency>
<groupId>com.github.tsantalis</groupId>
<artifactId>refactoring-miner</artifactId>
<version>2.1.0</version>
</dependency>
mvn install:install-file -Dfile=build/libs/RefactoringMiner-2.2.0.jar -DgroupId=com.github.tsantalis -DartifactId=refactoring-miner -Dversion=2.2.0 -Dpackaging=jar -DgeneratePom=false
- Build the project Click on build tab in the IntelliJ IDE and select Build Project to build RefMerge.
Task 2.2 - Optional
Looking at the tool RefMerge we can see that only a subset of the refactoring operations mentioned in the Readme.md of tool RefactoringMiner have been implemented. Extend RefMerge with a set of more refactoring operations. Write and run tests to ensure that they have been well implemented.