Skip to content

Commit

Permalink
Merge pull request #278 from Open-MBEE/bugfix/commit-loop
Browse files Browse the repository at this point in the history
fix commit retrieval loop.
  • Loading branch information
dlamoris authored May 21, 2024
2 parents d5d6e4d + fbfb634 commit f0423a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public RefJson save(RefJson refJson) {
scopedBranch.setTimestamp(Formats.FORMATTER.parse(refJson.getCreated(), Instant::from));
scopedBranch.setParentRefId(refJson.getParentRefId());
scopedBranch.setDocId(refJson.getDocId());
scopedBranch.setDeleted(Boolean.parseBoolean(refJson.getIsDeleted()));

//Setup global Branch object
Optional<Project> project = projectDAO.findByProjectId(refJson.getProjectId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.openmbee.mms.data.dao.BranchDAO;
import org.openmbee.mms.data.dao.CommitDAO;
import org.openmbee.mms.core.exceptions.InternalErrorException;
import org.openmbee.mms.core.config.Constants;
import org.openmbee.mms.data.domains.scoped.Branch;
import org.openmbee.mms.data.domains.scoped.Commit;
import org.openmbee.mms.rdb.repositories.BaseDAOImpl;
Expand Down Expand Up @@ -63,7 +64,7 @@ public Optional<Commit> findById(long id) {
String sql = "SELECT * FROM commits WHERE id = ?";

List<Commit> l = getConn()
.query(sql, new Object[]{id}, new CommitRowMapper());
.query(sql, new CommitRowMapper(), new Object[]{id});
return l.isEmpty() ? Optional.empty() : Optional.of(l.get(0));

}
Expand All @@ -72,7 +73,7 @@ public Optional<Commit> findByCommitId(String commitId) {
String sql = "SELECT * FROM commits WHERE commitid = ?";

List<Commit> l = getConn()
.query(sql, new Object[]{commitId}, new CommitRowMapper());
.query(sql, new CommitRowMapper(), new Object[]{commitId});
return l.isEmpty() ? Optional.empty() : Optional.of(l.get(0));

}
Expand Down Expand Up @@ -153,10 +154,11 @@ public List<Commit> findByRefAndTimestampAndLimit(Branch ref, Instant timestamp,
List<Commit> next = findByRefAndLimit(currentRef, currentCid, timestamp, currentLimit);
commits.addAll(next);

String oldRef = currentRef;
currentRef = ref.getParentRefId();
currentCid = ref.getParentCommit();

if (currentRef == null) {
if (currentRef == null || (currentRef.equals(Constants.MASTER_BRANCH) && oldRef.equals(Constants.MASTER_BRANCH))) {
break;
}
Optional<Branch> parent = branchRepository.findByBranchId(currentRef);
Expand Down

0 comments on commit f0423a7

Please sign in to comment.