Search code examples
gitrepo

Can Google repo report on current branch being ahead of remote?


In a single git repo I can do:

<project2 root dir>$ git status
On branch feature/feature_release
Your branch is ahead of 'origin/feature/feature_release' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

Using repo, though, I get:

$ repo status
project <project1 root dir>/ branch feature/feature_release
project <project2 root dir>/ branch feature/feature_release
project <project3 root dir>/ branch feature/feature_release

This doesn't tell me that, for instance, that project2 has local changes requiring pushing. If I try forall I get this:

$ repo forall -c "git status -sb"
...
## feature/feature_release...origin/feature/feature_release [ahead 1]
## HEAD (no branch)
## feature/feature_release...origin/feature/feature_release
## feature/feature_release...origin/feature/feature_release [ahead 1]
## feature/feature_release...origin/feature/feature_release [ahead 1]
## feature/feature_release...origin/feature/feature_release
## HEAD (no branch)
## HEAD (no branch)
...

Is there a built-in way with repo to do something like prepend the project name:

## <project1 root dir>/ feature/feature_release...origin/feature/feature_release [ahead 1]
## <project2 root dir>/ HEAD (no branch)
## <project3 root dir>/ feature/feature_release...origin/feature/feature_release
## <project4 root dir>/ feature/feature_release...origin/feature/feature_release [ahead 1]

I suppose beginning with repo start would help, but I never got that to work usefully.


Solution

  • I RTFMed a bit further, and the -p flag seems to be most of what I am looking for:

    $ repo forall -pc "git status -sb"
    ...
    project <project1 root dir>/
    ## feature/feature_release...origin/feature/feature_release [ahead 1]
    
    project <project2 root dir>/
    ## HEAD (no branch)
    
    project <project3 root dir>/
    ...