Skip to content

Commit

Permalink
Merge pull request #1021 from koordinates/merge-ancestor
Browse files Browse the repository at this point in the history
merge: Don't output commit message when merging ancestor
  • Loading branch information
craigds authored Nov 18, 2024
2 parents a6dd2c4 + 68933c0 commit 60b702d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _When adding new entries to the changelog, please include issue/PR numbers where
- Upgrade to PDAL 2.7 [#1005](https://github.com/koordinates/kart/pull/1005)
- Adds a `--drop-empty-geometry-features` option to `kart export`. [#1007](https://github.com/koordinates/kart/pull/1007)
- Adds diagnostic output to Kart when `KART_DIAGNOSTICS=1` environment variable is set. [#1013](https://github.com/koordinates/kart/pull/1013)
- In `kart merge --output-format=json`, the `message` field is now `null` if the merge is a no-op. [#1021](https://github.com/koordinates/kart/pull/1021)

## 0.15.3

Expand Down
1 change: 1 addition & 0 deletions kart/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def do_merge(
# We're up-to-date if we're trying to merge our own common ancestor.
if ancestor_id == theirs.id:
merge_jdict["noOp"] = True
merge_jdict["message"] = None
return merge_jdict

# "dryRun": True means we didn't actually do this
Expand Down
24 changes: 24 additions & 0 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,27 @@ def test_merge_into_branch_with_conflict(data_archive, tmp_path, cli_runner):
"conflicts": {"nz_pa_points_topo_150k": {"feature": 1}},
"dryRun": False,
}


def test_merge_ancestor_text(data_archive, cli_runner):
with data_archive("points") as repo_path:
# merge an ancestor commit
r = cli_runner.invoke(["merge", "HEAD^"])
assert r.exit_code == 0, r

# No merge commit is created, because the commit is an ancestor of the target branch
assert "Already up to date\n" in r.stdout
repo = KartRepo(repo_path)
assert repo.head.target.hex == H.POINTS.HEAD_SHA


def test_merge_ancestor_json(data_archive, cli_runner):
with data_archive("points") as repo_path:
repo = KartRepo(repo_path)
# new branch
r = cli_runner.invoke(["merge", "--output-format=json", "HEAD^"])
assert r.exit_code == 0, r
output = json.loads(r.stdout)["kart.merge/v1"]

assert output["noOp"]
assert output["message"] is None

0 comments on commit 60b702d

Please sign in to comment.