aboutsummaryrefslogtreecommitdiffstats
path: root/roles/git/files/git-shell-commands/set-desc
blob: 3d0a1be8addf1266e52710fe2905187be120a13c (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
#!/bin/sh
#
# ~/git-shell-commands/set-desc
#
# Set the description of an existing Git repository.
#
# Aaron LI
# 2017-08-22
#

if [ $# -lt 2 ]; then
    echo "Usage: set-desc <project.git> <description>"
    exit 1
fi

# Set the project name, adding `.git` extension if missing
project="${1%.[gG][iI][tT]}.git"
shift

if [ ! -d "${HOME}/${project}" ]; then
    echo "ERROR: repository '${project}' not exists!"
    exit 2
fi

description="$@"
if [ -n "${description}" ]; then
    echo "${description}" > ${HOME}/${project}/description
fi

echo "Set description of Git repository: ${project}"
echo "Description: $(cat ${HOME}/${project}/description)"