-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdump_git_info.sh
executable file
·36 lines (32 loc) · 1006 Bytes
/
dump_git_info.sh
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
# Save current git diff, log, status to output directory.
#
# Example usage:
# ./dump_git_info.sh /path/to/output/directory/
# ./dump_git_info.sh /path/to/output/directory/ /path/to/git/repo/
#
# Writes the following files to output_dir:
#
# git-status.txt: Output of git status -sb.
# git-log.txt : Output of
# git log --graph --pretty='format:%h -%d %s (%cd) <%an>'
# git-diff.txt : Output of git diff --patch --color=never
# git-head.txt : Output of git rev-parse HEAD
function usage {
echo "Usage: "
echo "$0 <output_directory> [<git_dir>]"
}
if [[ "$#" != 1 ]] && [[ "$#" != 2 ]] ; then
echo "Incorrect usage."
usage
exit 1
fi
OUTPUT_DIR=$(readlink -f "$1")
if [[ "$#" == 2 ]] ; then
cd "$2"
fi
git diff --patch --color=never > "${OUTPUT_DIR}/git-diff.patch"
git log --graph --pretty='format:%h -%d %s (%cd) <%an>' \
> "${OUTPUT_DIR}/git-log.txt"
git rev-parse HEAD > "${OUTPUT_DIR}/git-head.txt"
git status -sb > "${OUTPUT_DIR}/git-status.txt"