aboutsummaryrefslogtreecommitdiff
path: root/commit-updates
blob: 9fe77d78d1da3f9d35338e91e524a9dd0ecdddeb (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
31
32
33
34
35
36
#!/bin/bash
#
# Commit updates
#

# Parameters
PROJECT="$1"

# Git application we use
GIT="hit"

# Check if param is a project
if [ ! -z "$PROJECT" ] && [ -z "$2" ] && ( cd $PROJECT &> /dev/null ); then
  if ! $GIT status &> /dev/null; then
    cd $PROJECT &> /dev/null
    shift
  elif ! $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