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 #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 committed May 10, 2023
1 parent f44debc commit b55768a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,16 @@ 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, ', '(')

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 b55768a

Please sign in to comment.