Skip to content

Commit 4ec9e2e

Browse files
committed
show: Add 'Merge: {parentIDs}' line to text output
For consistency with `git show`. Useful for identifying a commit as a merge commit; it's hard to notice otherwise
1 parent ea6ec69 commit 4ec9e2e

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _When adding new entries to the changelog, please include issue/PR numbers where
88

99
- diff: Fixed garbled json-lines output sometimes when using `--add-feature-count-estimate` [#1040](https://github.com/koordinates/kart/issues/1040)
1010
- diff/show: Faster output for some large repositories (varies wildly) [#1038](https://github.com/koordinates/kart/issues/1038)
11+
- show: Text output now displays a 'Merge: {parentIDs}' line when showing a merge commit (consistent with `git show`) [#1043](https://github.com/koordinates/kart/issues/1043)
1112
- show: Added `--no-sort-keys` option to disable sorting of features by name/PK. Previously added to `diff` only
1213
- show: Added `--add-feature-count-estimate` option to add a feature count estimate to `json-lines` output. Previously added to `diff` only
1314

kart/text_diff_writer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def write_header(self):
4949
author_time_in_author_timezone = author_time_utc.astimezone(author_timezone)
5050

5151
click.secho(f"commit {self.commit.hex}", fg="yellow", **self.pecho)
52+
if len(self.commit.parent_ids) > 1:
53+
parents = self.commit.parents
54+
parent_ids_s = " ".join(str(x.short_id) for x in parents)
55+
click.secho(f"Merge: {parent_ids_s}", **self.pecho)
5256
click.secho(f"Author: {author.name} <{author.email}>", **self.pecho)
5357
click.secho(
5458
f'Date: {author_time_in_author_timezone.strftime("%c %z")}',

tests/point_cloud/test_conflicts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_resolve_conflict_with_workingcopy(cli_runner, data_archive, requires_pd
168168

169169
r = cli_runner.invoke(["show", "HEAD", "auckland:tile:auckland_0_0"])
170170
assert r.exit_code == 0, r.stderr
171-
assert r.stdout.splitlines()[4:] == [
171+
assert r.stdout.splitlines()[5:] == [
172172
' Merge with "theirs_branch"',
173173
"",
174174
"--- auckland:tile:auckland_0_0",
@@ -226,7 +226,7 @@ def test_resolve_conflict_with_file(cli_runner, data_archive, requires_pdal, tmp
226226

227227
r = cli_runner.invoke(["show", "HEAD", "auckland:tile:auckland_0_0"])
228228
assert r.exit_code == 0, r.stderr
229-
assert r.stdout.splitlines()[4:] == [
229+
assert r.stdout.splitlines()[5:] == [
230230
' Merge with "theirs_branch"',
231231
"",
232232
"--- auckland:tile:auckland_0_0",

tests/test_resolve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def test_resolve_schema_conflict(data_working_copy, cli_runner):
379379
["show", "HEAD", "--", "nz_waca_adjustments:feature:9999999"]
380380
)
381381
assert r.exit_code == 0, r.stderr
382-
assert r.stdout.splitlines()[4:] == [
382+
assert r.stdout.splitlines()[5:] == [
383383
" Merge with 'theirs_branch'",
384384
"",
385385
"--- nz_waca_adjustments:feature:9999999",

0 commit comments

Comments
 (0)