File: git-mproj

package info (click to toggle)
ecbuild 3.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,068 kB
  • sloc: sh: 1,404; perl: 732; f90: 472; cpp: 466; python: 383; ansic: 304; fortran: 43; makefile: 15
file content (54 lines) | stat: -rwxr-xr-x 1,219 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#
# (C) Copyright 2011- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

#
# git-proj: status, branch, checkout
#

txtbld=$(tput bold)             #  bold
bldblu=${txtbld}$(tput setaf 6) #  bold cyan
txtrst=$(tput sgr0)             #  reset

dashless=$(basename "$0" | sed -e 's/-/ /')
USAGE="$dashless <command> [options...]"

SUBDIRECTORY_OK="yes"

PATH=$(git --exec-path):$PATH
. git-sh-setup

require_work_tree_exists

# go to top

cd_to_toplevel
cd ..

# check option for number of levels
nlevels=$(git config --global --int --get mproj.levels)
if [ "$nlevels" != "" ]
then
    nlevels="-maxdepth $nlevels"
fi

# do it

for d in $( find $PWD $nlevels -type d -iname ".git" )
do
    gdir=$(dirname $d)
    proj=$(basename $gdir)
    pushd $gdir > /dev/null
    branch=$(git symbolic-ref --short HEAD)
    echo -e "${bldblu}---> $proj ($branch)${txtrst}"
    git "$@"
    popd > /dev/null
done