aboutsummaryrefslogtreecommitdiff
path: root/commit-updates
blob: a70d3c98d19131f4bb9c9279dc433b21af8362a7 (plain)
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
#!/bin/bash
#
# Commit updates
#

# Parameters
PROJECT="$1"

# Check if param is a project
if [ ! -z "$PROJECT" ] && [ -z "$2" ] && ( cd $PROJECT &> /dev/null ); then
  if ! git status $PROJECT | grep -q "$PROJECT (new commits)"; then
    cd $PROJECT &> /dev/null
    shift
  fi
fi

# Commit message
ARGS="$*"

# Simply update commit
if git status &> /dev/null; then
  if [ ! -z "$ARGS" ]; then
    commit "Updates $ARGS"
  else
    commit "Updates $(basename `pwd`)"
  fi
else
  mr commit -m "Updates"
  mr fetch
fi