-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit-functions.sh
47 lines (36 loc) · 912 Bytes
/
git-functions.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
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
function switchBranch() {
TGT_BRANCH="$1"
git checkout "$TGT_BRANCH"
}
function showStatusInShortFormat() {
git status -s
}
function findConflictingFiles() {
SRC_BRANCH="$1"
TGT_BRANCH="$2"
git checkout -q "${TGT_BRANCH}"
# git pull origin "${TGT_BRANCH}"
git checkout -q -b temp_merge_branch
git merge -q "$SRC_BRANCH" 1> /dev/null
conflicts=$(git diff --name-only --diff-filter=U)
git merge --abort
git checkout -q "${TGT_BRANCH}"
git branch -q -D temp_merge_branch
echo "$conflicts"
}
function getLastAuthorOfFile() {
BRANCH="$1"
FILE="$2"
git checkout -q "$BRANCH"
git log -1 --pretty=format:"%an" "${FILE}"
}
function getLastAuthorOfFiles() {
BRANCH="$1"
FILES="$2"
for FILE in "${FILES[@]}"
do
author=$(getLastAuthorOfFile "$BRANCH" "$FILE")
echo "${FILE}: ${author}"
done
}