zephyrproject-rtos/west

west command to provide info about all repos which are not in the manifest revision

aescolar opened this issue · 5 comments

Similarly to how repo status works, it would be very nice if west status also provided information about all projects which are off the manifest revision; not just with uncommitted changes, but also in another sha/branch/tag.

This would facilitate working with several local changes to sub-projects projects.

Duplicate of

(That other issue is all over the place, so let me be a bit clearer about what I would hope, which would cover my needs)

For each project:

  1. If the project has been moved to a different commit (different that the one west last took it to(^1) in the last update), to print a line saying so (just printing the output of git status would be fine)(^2).
  2. If the project has an unclean git status, print the output of git status
  3. Otherwise no output whatsoever for that project (not even the project name)

(^1) I understand this is manifest-rev. So the condition would be if that project is not in manifest-rev.
(^2) Repo even tells you if you checked out a different branch but are still in the same commit. The benefit of this is marginal. So telling or not about this case is not so important.

You can be even nicer and provide a return code > 0 to the shell if any project hit 1. or 2.

The command can be called whatever.
The command should not change anything locally or in the .west or .git folders, or do anything smarter than that.

If the user moved manifest-rev on his own, that is not something this command should protect against.

With plain bash, something like this would do what I was hoping:

#! /usr/bin/env bash

exit_code=0
projects=`west list -f {abspath} | tail -n +2` #Skip the manifest repo
manifets_repo=`west list -f {abspath} 2> /dev/null | head -n 1`
cd $manifets_repo
if [[ -n $(git status -s) ]]; then
   echo -e "\033[0;32m=== status of $manifets_repo\033[0m"
   git status
   exit_code=1
fi
for project in $projects; do
    cd $project
    if [[ $(git rev-parse manifest-rev) != $(git rev-parse HEAD) || -n $(git status -s) ]]; then
       echo -e "\033[0;32m=== status of $project\033[0m"
       git status
       exit_code=1
    fi
done
exit $exit_code

(That other issue is all over the place, so let me be a bit clearer about what I would hope, which would cover my needs)

There was indeed a lot of alternatives discussed in #548. However I think the simplest one and the one I defended the most was exactly what you're asking here.

AFAIK it was closed by @mbolivar-nordic like this, verbatim:

west status, as a wrapper around git status, reports status relative to HEAD, not manifest-rev

I hope I'm wrong but I'm not holding my breath.

With plain bash, something like this would do what I was hoping:

I highly recommend the excellent tool apt/dnf install shellcheck :-)

Off-topic sorry.

@aescolar thanks for the clear and concise issue description.

Indeed I don't think it is a good idea to change the semantics of west status: the west commands that are just wrappers for git commands with the same names should be as simple and stupid as possible IMO, so west status should work like git status, which compares worktree+index with HEAD.

The command can be called whatever.

I'm proposing west compare here: #643

Please test it and provide feedback. If it matches your expectations, I will write test cases and try to get it merged.