Merge pull request #12444 from thingsboard/fix/vc-check-access
VC: fix invalid error when checking access to repository
This commit is contained in:
commit
587615c0d6
@ -94,6 +94,10 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.eclipse.jgit.api.ListBranchCommand.ListMode;
|
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
|
@Slf4j
|
||||||
public class GitRepository {
|
public class GitRepository {
|
||||||
@ -358,8 +362,10 @@ public class GitRepository {
|
|||||||
result.forEach(pushResult -> {
|
result.forEach(pushResult -> {
|
||||||
for (RemoteRefUpdate update : pushResult.getRemoteUpdates()) {
|
for (RemoteRefUpdate update : pushResult.getRemoteUpdates()) {
|
||||||
RemoteRefUpdate.Status status = update.getStatus();
|
RemoteRefUpdate.Status status = update.getStatus();
|
||||||
if (status != RemoteRefUpdate.Status.OK && status != RemoteRefUpdate.Status.UP_TO_DATE) {
|
if (status == REJECTED_NONFASTFORWARD || status == REJECTED_NODELETE ||
|
||||||
throw new RuntimeException("Failed to push changes: " + Optional.ofNullable(update.getMessage()).orElseGet(status::name));
|
status == REJECTED_REMOTE_CHANGED || status == REJECTED_OTHER_REASON) {
|
||||||
|
throw new RuntimeException("Remote repository answered with error: " +
|
||||||
|
Optional.ofNullable(update.getMessage()).orElseGet(status::name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user