Skip to content

Commit eeaf8a1

Browse files
committed
Fix the NPE.
1 parent 135514a commit eeaf8a1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- When the remote branch was missing (as in a bare checkout), the user got an NPE rather than a nice error message. ([#16](https://github.com/diffplug/spotless-changelog/issues/16))
810

911
## [2.0.0] - 2020-06-16
1012
### Changed

spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/GitActions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 DiffPlug
2+
* Copyright (C) 2019-2021 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ public void checkCanPush() throws GitAPIException, IOException {
6363
Ref ref = repository.getRefDatabase().exactRef(Constants.R_HEADS + cfg.branch);
6464
Objects.requireNonNull(ref, "Expected ref " + Constants.R_HEADS + cfg.branch);
6565
Ref remoteRef = repository.getRefDatabase().exactRef(Constants.R_REMOTES + cfg.remote + "/" + cfg.branch);
66-
Objects.requireNonNull(ref, "Expected ref " + Constants.R_REMOTES + cfg.remote + "/" + cfg.branch);
66+
Objects.requireNonNull(remoteRef, "Expected ref " + Constants.R_REMOTES + cfg.remote + "/" + cfg.branch);
6767
if (!ref.getObjectId().equals(remoteRef.getObjectId())) {
6868
throw new IllegalStateException("Local branch " + cfg.branch + " is out of sync with " + cfg.remote + ", so we can't safely push it automatically.");
6969
}

0 commit comments

Comments
 (0)