Browse Source
Merge pull request #12444 from thingsboard/fix/vc-check-access
VC: fix invalid error when checking access to repository
pull/12445/head
Viacheslav Klimov
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
8 additions and
2 deletions
-
common/version-control/src/main/java/org/thingsboard/server/service/sync/vc/GitRepository.java
|
|
|
@ -94,6 +94,10 @@ import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static org.eclipse.jgit.api.ListBranchCommand.ListMode; |
|
|
|
import static org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_NODELETE; |
|
|
|
import static org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD; |
|
|
|
import static org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON; |
|
|
|
import static org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
public class GitRepository { |
|
|
|
@ -358,8 +362,10 @@ public class GitRepository { |
|
|
|
result.forEach(pushResult -> { |
|
|
|
for (RemoteRefUpdate update : pushResult.getRemoteUpdates()) { |
|
|
|
RemoteRefUpdate.Status status = update.getStatus(); |
|
|
|
if (status != RemoteRefUpdate.Status.OK && status != RemoteRefUpdate.Status.UP_TO_DATE) { |
|
|
|
throw new RuntimeException("Failed to push changes: " + Optional.ofNullable(update.getMessage()).orElseGet(status::name)); |
|
|
|
if (status == REJECTED_NONFASTFORWARD || status == REJECTED_NODELETE || |
|
|
|
status == REJECTED_REMOTE_CHANGED || status == REJECTED_OTHER_REASON) { |
|
|
|
throw new RuntimeException("Remote repository answered with error: " + |
|
|
|
Optional.ofNullable(update.getMessage()).orElseGet(status::name)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|