Skip to content

Commit

Permalink
Add 'committer' column to DB table 'commit'
Browse files Browse the repository at this point in the history
For better traceability and to enable subsequent analyses, we now always
store the committer of a commit in the database during commit analysis
in addition to the commit's author.

To add the missing column in existing databases created with previous
schemas, run the following command inside MySQL:

ALTER TABLE `codeface`.`commit`
ADD COLUMN `committer`
    BIGINT NOT NULL COMMENT ''
    AFTER `author`,
ADD CONSTRAINT `commit_committer`
    FOREIGN KEY (`committer`)
    REFERENCES `codeface`.`person` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
DROP INDEX `commit_person_idx`,
ADD INDEX `commit_person_idx`
    (`author` ASC, `committer` ASC)  COMMENT '';

This fixes siemens#59.

Signed-off-by: Claus Hunsen <[email protected]>
  • Loading branch information
clhunsen authored and ecklbarb committed Dec 18, 2017
1 parent 325a16c commit 5d885fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions codeface/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ def writeCommitData2File(cmtlist, id_mgr, outdir, releaseRangeID, dbm, conf,
values = {"commitHash" : cmt.id,
"commitDate" : tstamp_to_sql(int(cmt.getCdate())),
"author" : cmt.getAuthorPI().getID(),
"committer": cmt.getCommitterPI().getID(),
"authorDate" : tstamp_to_sql(int(cmt.adate)),
"authorTimeOffset" : cmt.adate_tz,
"projectId" : projectID,
Expand Down Expand Up @@ -1379,13 +1380,14 @@ def populatePersonDB(cmtlist, id_mgr, link_type=None):
cmt.setAuthorPI(pi)
pi.addCommit(cmt)

#create person for committer
ID_c = id_mgr.getPersonID(cmt.getCommitterName())
pi_c = id_mgr.getPI(ID_c)
cmt.setCommitterPI(pi_c)

if link_type in \
(LinkType.proximity, LinkType.committer2author,
LinkType.file, LinkType.feature, LinkType.feature_file):
#create person for committer
ID_c = id_mgr.getPersonID(cmt.getCommitterName())
pi_c = id_mgr.getPI(ID_c)
cmt.setCommitterPI(pi_c)
if ID_c != ID:
# Only add the commit to the committer's person instance
# if committer and author differ, otherwise contributions
Expand Down
8 changes: 7 additions & 1 deletion datamodel/codeface_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ CREATE TABLE IF NOT EXISTS `codeface`.`commit` (
`authorTimeOffset` INT NULL DEFAULT NULL COMMENT '',
`authorTimezones` VARCHAR(255) NULL DEFAULT NULL COMMENT '',
`author` BIGINT NOT NULL COMMENT '',
`committer` BIGINT NOT NULL COMMENT '',
`projectId` BIGINT NOT NULL COMMENT '',
`ChangedFiles` INT NULL DEFAULT NULL COMMENT '',
`AddedLines` INT NULL DEFAULT NULL COMMENT '',
Expand All @@ -338,6 +339,11 @@ CREATE TABLE IF NOT EXISTS `codeface`.`commit` (
REFERENCES `codeface`.`person` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `commit_committer`
FOREIGN KEY (`committer`)
REFERENCES `codeface`.`person` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `commit_project`
FOREIGN KEY (`projectId`)
REFERENCES `codeface`.`project` (`id`)
Expand All @@ -350,7 +356,7 @@ CREATE TABLE IF NOT EXISTS `codeface`.`commit` (
ON UPDATE CASCADE)
ENGINE = InnoDB;

CREATE INDEX `commit_person_idx` ON `codeface`.`commit` (`author` ASC) COMMENT '';
CREATE INDEX `commit_person_idx` ON `codeface`.`commit` (`author` ASC, `committer` ASC) COMMENT '';

CREATE INDEX `commit_project_idx` ON `codeface`.`commit` (`projectId` ASC) COMMENT '';

Expand Down

0 comments on commit 5d885fc

Please sign in to comment.