public String getCommitsAsString() { final StringBuffer b = new StringBuffer(); int i = 0; for(ConstructChange chg: this.changes) { if(i++>0) b.append(","); b.append(chg.getCommit()); } return b.toString(); }
/** * Checks if two commits have no intermediate commits between them and logs it to console */ private void checkFollowingCommits(){ for(int i=1; i<this.changes.size(); i++){ boolean isFollowing = isFollowingCommit(Iterables.get(changes, i-1), Iterables.get(changes, i)); log.info("Commits " + Iterables.get(changes, i-1).getCommit() + " and " + Iterables.get(changes, i).getCommit() + " are " + (isFollowing ? "" : "not") + " sequential"); } }
@Override public final String toString() { final StringBuilder builder = new StringBuilder(); builder.append("[").append(this.getId()).append(":").append(this.getCommit()).append("]"); return builder.toString(); }
public JsonElement toJson() { final JsonObject json = new JsonObject(); json.addProperty("path", this.path); final JsonArray revs = new JsonArray(); for(ConstructChange c: this.changes) { revs.add(new JsonPrimitive(c.getCommit())); } json.add("revisions", revs); final boolean is_mod = this.getOverallChangeType().equals(ConstructChangeType.MOD); json.addProperty("is_modification", (is_mod ? 1 : 0) ); if(is_mod) { json.addProperty("fixed", (this.containsFix() ? 1 : 0) ); json.addProperty("relaxed_comparison", (this.relaxedEntityComparison ? 1 : 0) ); } return json; }
public void addConstructChange(ConstructChange _construct_change) throws IllegalArgumentException { String path = _construct_change.getRepoPath(); if(path==null) { ArchiveFixContainmentCheck.log.warn("Construct change with commit [" + _construct_change.getCommit()+ "] has not path information"); path = ""; } //throw new IllegalArgumentException("Cannot analyze construct fix containment without path information"); OrderedCommitsForPath commits_per_path = this.commits.get(path); if(commits_per_path==null) { commits_per_path = new OrderedCommitsForPath(this.constructId, this.ja, path); this.commits.put(path, commits_per_path); } commits_per_path.addConstructChange(_construct_change); }/* old public void addConstructChange(ConstructChange _construct_change) throws IllegalArgumentException {
public ConstructFixContainmentCheck(ConstructId _c, JarAnalyzer _ja, ConstructChange _cc) { this.constructId = _c; this.ja = _ja; this.repo = _cc.getRepo(); this.repoPath = _cc.getRepoPath(); this.commit = _cc.getCommit(); }
/** * Checks and logs if there is more than one commit fixing this construct */ private void checkIfManyCommits(){ if ( this.changes.size() != 1 ){ log.info("more than one commit found fixing this construct"); checkFollowingCommits(); log.info(getCommitsAsString()); for ( ConstructChange cc1 : this.changes ){ log.info("Commit: " + cc1.getCommit()); SignatureChange diffChange = getDiffChange(cc1); log.info("diffchange . get modifications"); for ( SourceCodeChange o1 : ASTSignatureChange.toSourceCodeChanges(diffChange.getModifications()) ) { log.info(o1.toString()); } } } }
JsonObject json = new JsonObject(); json.addProperty("repo", cc.getRepo()); json.addProperty("commit", cc.getCommit()); json.addProperty("repoPath", cc.getRepoPath()); json.add("constructId", gson.toJsonTree(cc.getConstructId()));
cc.addProperty("commit", c.getCommit()); cc.addProperty("repoPath", c.getRepoPath()); JsonObject constructId = new JsonObject();