Skip to content

Commit

Permalink
added cli option --include-commits. v0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanodallapalma committed Nov 5, 2020
1 parent d8a8b11 commit b1757d2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 97 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## [0.8.3]
- Added cli option (--include-commits) to include a list of fixing-commits. The purpose is to save time during future
analyses.
- Upgraded dependencies.

## [0.8.0]
- Added two more options to the CLI to mine fixing-commits and fixed-files
- Refactored application
Expand Down
11 changes: 6 additions & 5 deletions docs/cli/mine.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ optional arguments:
-b, --branch BRANCH the repository branch to mine (default: master)
--exclude-commits EXCLUDE_COMMITS
the path to a JSON file containing the list of commit hashes to exclude
--include-commits INCLUDE_COMMITS
the path to a JSON file containing the list of commit hashes to include
--exclude-files EXCLUDE_FILES
the path to a JSON file containing the list of FixedFiles to exclude
--verbose show log
Expand All @@ -24,11 +26,10 @@ optional arguments:
!!! note "Output"
Running this command will generate the following report files:

* `dest/failure-prone-files.html`
* `dest/failure-prone-files.json`
* `dest/fixing-commits.json` containing the list of fixing-commit hashes;
* `dest/fixed-files.json` containing the list of FixedFile objects (if mined `fixed-files` or `failure-prone-files`);
* `dest/failure-prone-files.json` containing the list of FailureProne objects (if mined `failure-prone-files`);

File `failure-prone-files.json` is a list of dictionaries containing the `filepath` relative to the repository root,
the `commit` hash at which the file was failure-prone, and the respective `fixing-commit` hash.

!!! warning "Requirements"
To properly use this command you **MUST** add the following to your environment variables:
Expand All @@ -41,7 +42,7 @@ optional arguments:

* `TMP_REPOSITORIES_DIR=<path/to/tmp/repositories/>` to temporary clone the remote repository for analysis.
Please, note that the repository will be cloned in this folder but not deleted. The latter step is left to the user,
when and if needed.
when and if needed. **Note:** this variable is not needed if using the Docker image.



Expand Down
18 changes: 14 additions & 4 deletions repominer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
from repominer.mining.base import BaseMiner
from repominer.mining.ansible import AnsibleMiner
from repominer.mining.tosca import ToscaMiner
# from repominer.report import create_report

VERSION = '0.8.2'
VERSION = '0.8.3'


def valid_dir_or_url(x: str) -> str:
Expand Down Expand Up @@ -96,6 +95,12 @@ def set_mine_parser(subparsers):
type=valid_file,
help='the path to a JSON file containing the list of commit hashes to exclude')

parser.add_argument('--include-commits',
action='store',
dest='include_commits',
type=valid_file,
help='the path to a JSON file containing the list of commit hashes to include')

parser.add_argument('--exclude-files',
action='store',
dest='exclude_files',
Expand Down Expand Up @@ -165,13 +170,18 @@ def get_parser():
return parser


def mine_fixing_commits(miner: BaseMiner, verbose: bool, dest: str, exclude_commits: str = None):
def mine_fixing_commits(miner: BaseMiner, verbose: bool, dest: str, exclude_commits: str = None, include_commits: str = None):

if exclude_commits:
with open(exclude_commits, 'r') as f:
commits = json.load(f)
miner.exclude_commits = set(commits)

if include_commits:
with open(include_commits, 'r') as f:
commits = json.load(f)
miner.fixing_commits = commits

if verbose:
print('Identifying fixing-commits from closed issues related to bugs')

Expand Down Expand Up @@ -260,7 +270,7 @@ def mine(args: Namespace):
else:
miner = ToscaMiner(url_to_repo=url_to_repo, branch=args.branch)

mine_fixing_commits(miner, args.verbose, args.dest, args.exclude_commits)
mine_fixing_commits(miner, args.verbose, args.dest, args.exclude_commits, args.include_commits)

if args.info_to_mine in ('fixed-files', 'failure-prone-files'):
mine_fixed_files(miner, args.verbose, args.dest, args.exclude_files)
Expand Down
85 changes: 0 additions & 85 deletions repominer/report.py

This file was deleted.

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ansiblemetrics~=0.3.6
pandas~=1.1.3
ansiblemetrics~=0.3.7
pandas~=1.1.4
pydriller~=1.15.2
pygithub~=1.53
python-gitlab~=2.5.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
with open("README.md", "r") as fh:
long_description = fh.read()

VERSION = '0.8.2'
VERSION = '0.8.3'

setup(name='repository-miner',
version=VERSION,
Expand Down

0 comments on commit b1757d2

Please sign in to comment.