diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/git/GitRepositoryFacade.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/git/GitRepositoryFacade.java index 43d6eb5224..869536bcd0 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/git/GitRepositoryFacade.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/dao/git/GitRepositoryFacade.java @@ -121,7 +121,9 @@ public GitRepository create(Project project, GitProvider gitProvider, Users user } public GitRepository updateRepository(GitRepository repository) { - return super.update(repository); + repository = em.merge(repository); + em.flush(); + return repository; } public GitRepository updateRepositoryCid(GitRepository repository, String pid) { diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/git/GitExecutionController.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/git/GitExecutionController.java index 81e365ecce..49d847f7d3 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/git/GitExecutionController.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/git/GitExecutionController.java @@ -195,7 +195,7 @@ public synchronized GitOpExecution updateGitExecutionState(Project project, User GitOpExecution execution = getExecutionInRepository(repository, executionId); if (newState.isFinalState()) { if (newState == GitOpExecutionState.SUCCESS) { - finalizeSuccessfulExecution(execution, stateDTO); + repository = finalizeSuccessfulExecution(execution, stateDTO); } if (newState == GitOpExecutionState.CANCELLED) { gitCommandExecutor.cancelGitExecution(execution, stateDTO.getMessage()); @@ -213,11 +213,13 @@ public synchronized GitOpExecution updateGitExecutionState(Project project, User return gitOpExecutionFacade.updateState(execution, newState, stateDTO.getMessage()); } - private void finalizeSuccessfulExecution(GitOpExecution execution, GitCommandExecutionStateUpdateDTO stateDTO) { + private GitRepository finalizeSuccessfulExecution(GitOpExecution execution, + GitCommandExecutionStateUpdateDTO stateDTO) { //Every successful operation should update the repository current commit and branch GitRepository repository = execution.getRepository(); repository.setCurrentBranch(stateDTO.getBranch()); repository.setCurrentCommit(stateDTO.getCommitHash()); + GitRepository updateRepository = gitRepositoryFacade.updateRepository(repository); GitCommandConfiguration executedCommandConfig = execution.getGitCommandConfiguration(); if (executedCommandConfig.getCommandType() == GitCommandType.DELETE_BRANCH) { //if we deleted a branch then we should also delete all the commits for this branch @@ -232,5 +234,6 @@ private void finalizeSuccessfulExecution(GitOpExecution execution, GitCommandExe remotesJson), repository); } } + return updateRepository; } }