GitPushSource (@NotNull GitRepository repository) { GitLocalBranch currentBranch = repository.getCurrentBranch(); return currentBranch != null ? GitPushSource.create(currentBranch) : GitPushSource.createDetached(Objects.requireNonNull(repository.getCurrentRevision())); // fresh repository is on branch }