Skip to content

Commit

Permalink
compare: add --decorate
Browse files Browse the repository at this point in the history
When a project is not on the `manifest-rev` it will often be on a branch
or tag. Use the `%d` format to make `west compare` show that
information.

As discussed in zephyrproject-rtos#643 and before, git status cannot be fully trusted to
display branch information.

Sample new output:
```
west compare
=== zephyr (zephyr):
--- manifest-rev: e40859f78712 (some_tag) Revert "dma: dw: Do ...
            HEAD: e803b77463b4 (zephyrproject/main) samples: net: ...
--- status:
    HEAD detached at zephyrproject/main
    nothing to commit, working tree clean
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
  • Loading branch information
marc-hb authored and mbolivar-nordic committed May 15, 2023
1 parent 421d122 commit f6f5cf6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,19 @@ def print_rev_info(self, project):
return

def rev_info(rev):
return project.git(
['log', '-1', '--color=never', '--pretty=%h %s', rev],
title = project.git(
['log', '-1', '--color=never', '--pretty=%h%d %s',
'--decorate-refs-exclude=refs/heads/manifest-rev',
rev],
capture_stdout=True,
capture_stderr=True).stdout.decode().rstrip()
# "HEAD" is special; '--decorate-refs-exclude=HEAD' doesn't work.
# Fortunately it's always first.
return (
title.replace('(HEAD) ', '').replace('(HEAD, ', '(')
.replace('(HEAD -> ', '(')
)

head_info = rev_info('HEAD')
# If manifest-rev is missing, we already failed earlier.
manifest_rev_info = rev_info('manifest-rev')
Expand Down

0 comments on commit f6f5cf6

Please sign in to comment.