Skip to content

Commit 4d592a7

Browse files
author
Lars Schneider
committed
v2.0.3 drop
1 parent c17b676 commit 4d592a7

32 files changed

+914
-233
lines changed

clean-checkout.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#/
3-
#/ Clean checkout of a branch/tag/commit including all submodules.
3+
#/ Clean checkout of a branch/tag/commit including all submodules
44
#/ Attention: This is going to delete all local changes!
55
#/
66
#/ Usage: git $KIT_ID clean-checkout <options> <branch>

cleanup-branches.sh

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
#/
3+
#/ Cleanup Branches
4+
#/
5+
#/ Delete (all or merged) branches that are prefixed with the current
6+
#/ username.
7+
#/
8+
#/ Usage: git $KIT_ID cleanup-branches
9+
#/ git $KIT_ID cub
10+
#/
11+
set -e
12+
13+
KIT_PATH=$(dirname "$0")
14+
. "$KIT_PATH/enterprise.constants"
15+
. "$KIT_PATH/lib/setup_helpers.sh"
16+
17+
BASE_BRANCH=$(git config 'adsk.pr-base-default') ||
18+
error_exit 'No base branch found.
19+
Please configure your default Pull Request base with:
20+
git config --local adsk.pr-base-default YourBaseBranch'
21+
22+
USERNAME=$(git config adsk.github.account) ||
23+
error_exit "Git configuration error. Please run 'git adsk' and/or contact @githelp on #tech-git!"
24+
25+
REMOTE=origin
26+
if ! git remote | grep $REMOTE >/dev/null 2>&1
27+
then
28+
error_exit "Remote $REMOTE not found."
29+
fi
30+
31+
echo 'Which branches do you want to delete?'
32+
PS3='Please enter your choice: '
33+
OPTIONS=("Delete '$USERNAME/*' branches merged to '$BASE_BRANCH'" "Delete all '$USERNAME/*' branches" "Abort")
34+
select answer in "${OPTIONS[@]}"
35+
do
36+
case $((REPLY)) in
37+
1) LOCAL_DELETE_OPTION="--merged $BASE_BRANCH";
38+
REMOTE_DELETE_OPTION="--merged $REMOTE/$BASE_BRANCH";
39+
break;;
40+
2) LOCAL_DELETE_OPTION='';
41+
REMOTE_DELETE_OPTION='';
42+
break;;
43+
3) exit;;
44+
*) echo 'Invalid option.';;
45+
esac
46+
done
47+
48+
# Delete any tracking branches that no longer exist on the remote
49+
# This way we avoid "error: unable to delete 'xyz': remote ref does not exist"
50+
git fetch --quiet --prune $REMOTE
51+
52+
LOCAL_DELETE=$(git branch $LOCAL_DELETE_OPTION | grep "^ *$USERNAME/" | cat)
53+
REMOTE_DELETE=$(git branch --remotes $REMOTE_DELETE_OPTION | grep "^ *$REMOTE/$USERNAME/" | cat)
54+
55+
if [ -z "$LOCAL_DELETE" ] && [ -z "$REMOTE_DELETE" ]
56+
then
57+
print_success "No branches found - all clean!"
58+
exit 0
59+
fi
60+
61+
echo ''
62+
echo 'The following branches are about to be deleted:'
63+
echo "$LOCAL_DELETE"
64+
echo "$REMOTE_DELETE"
65+
66+
PS3='Please enter your choice: '
67+
OPTIONS=('proceed' 'abort')
68+
select OPT in "${OPTIONS[@]}"
69+
do
70+
echo ''
71+
case $OPT in
72+
proceed) break;;
73+
abort) exit 1; break;;
74+
*) echo 'Invalid option.';;
75+
esac
76+
done
77+
78+
[ -z "$LOCAL_DELETE" ] || git branch --delete --force $(echo $LOCAL_DELETE | tr -d '\n')
79+
[ -z "$REMOTE_DELETE" ] || git push --delete origin $(echo $REMOTE_DELETE | sed $"s/^ *$REMOTE\\// /" | tr -d '\n')
80+

clone-no-lfs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#/
3-
#/ Clone a Git repository without downloading any Git LFS content.
3+
#/ Clone a Git repository without downloading any Git LFS content
44
#/
55
#/ Usage: git $KIT_ID clone-no-lfs <repository URL> [<target directory>]
66
#/

clone.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#/
3-
#/ Fast clone a repository with Git LFS files and submodules.
3+
#/ Clone a repository with Git LFS files and submodules
44
#/
55
#/ Usage: git $KIT_ID clone <repository URL> [<target directory>]
66
#/

config.include

+78-26
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
# c.f. https://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
1313
longpaths = true
1414

15-
[help]
16-
autocorrect = 1
17-
1815
[color]
1916
diff = auto
2017
status = auto
@@ -38,6 +35,14 @@
3835
[lfs]
3936
batch = true
4037
ConcurrentTransfers = 10
38+
# If the Git LFS locking feature is used, then Git LFS will set lockable files
39+
# to "readonly" by default. This is implemented with a Git LFS "post-checkout"
40+
# hook. Git LFS can skip this hook if no file is locked. However, Git LFS needs
41+
# to traverse the entire tree to find all ".gitattributes" and check for locked
42+
# files. In a large tree (e.g. >20k directories, >300k files) this can take a
43+
# while. Instruct Git LFS to not set lockable files to "readonly". This skips
44+
# the "post-checkout" entirely and speeds up Git LFS for large repositories.
45+
SetLockableReadonly = false
4146

4247
[lfs "transfer"]
4348
maxretries = 10
@@ -48,6 +53,17 @@
4853
process = git-lfs filter-process
4954
required = true
5055

56+
[lfs "https://git.company.com/"]
57+
locksverify = true
58+
59+
60+
###############################################################################
61+
# Use HTTPS protocol instead of Git protocol
62+
###############################################################################
63+
[url "https://git.company.com/"]
64+
insteadOf = "git://git.company.com/"
65+
pushInsteadOf = "git://git.company.com/"
66+
5167

5268
###############################################################################
5369
# Configure push protection to public Git hosting services
@@ -69,34 +85,54 @@
6985
st=status
7086
br=branch
7187
lol = "log --pretty=oneline --abbrev-commit --graph --decorate"
88+
lola = "log --pretty=oneline --abbrev-commit --graph --decorate --all"
7289
prlog = "log --pretty=oneline --abbrev-commit --graph --decorate --first-parent"
7390

7491

7592
###############################################################################
7693
# Enterprise Config setup command
7794
###############################################################################
78-
adsk = "!f() { \
79-
KIT_PATH=$(dirname \"$(git config include.path)\") && \
80-
ENV=$(git config adsk.environment || true) && \
81-
COMMAND=$1 && \
82-
if [ -n \"$COMMAND\" ]; then \
83-
shift 1; \
84-
fi && \
85-
if [ -z \"$COMMAND\" ] || [ \"$COMMAND\" = \"setup\" ]; then \
86-
TMP_SETUP=$(mktemp -t git-enterprise-kit.XXXXXX) && \
87-
cp \"$KIT_PATH/setup.sh\" \"$TMP_SETUP\" && \
88-
bash \"$TMP_SETUP\" \"$KIT_PATH\" \"$@\" && \
89-
rm \"$TMP_SETUP\"; \
90-
elif [ \"$COMMAND\" = \"install\" ]; then \
91-
echo \"Enterprise config already installed!\"; \
92-
elif [ -n \"$ENV\" ] && [ -e "$KIT_PATH/envs/$ENV/$COMMAND.sh" ]; then \
93-
bash \"$KIT_PATH/envs/$ENV/$COMMAND.sh\" \"$@\"; \
94-
elif [ -e \"$KIT_PATH/$COMMAND.sh\" ]; then \
95-
bash \"$KIT_PATH/$COMMAND.sh\" \"$@\"; \
96-
else \
97-
echo \"Enterprise Config command '$COMMAND' not found.\"; \
98-
fi \
99-
}; f"
95+
#
96+
# Jenkins Git Plugin 3.4.1 cannot handle mutplie lines in config files.
97+
# Therefore, we have to reformat the code below into the one line.
98+
#
99+
# adsk = "!f() { \
100+
# KIT_PATH=$(dirname \"$(git config include.path)\") && \
101+
# ENV=$(git config adsk.environment || true) && \
102+
# COMMAND=$1 && \
103+
# if [ -n \"$COMMAND\" ]; then \
104+
# shift 1; \
105+
# fi && \
106+
# if [ \"$KIT_PATH\" = \"adsk-git\" ]; then \
107+
# case $(uname -s) in \
108+
# MINGW32_NT*) KIT_PATH=/mingw32/etc/adsk-git;; \
109+
# MINGW64_NT*) KIT_PATH=/mingw64/etc/adsk-git;; \
110+
# esac \
111+
# fi && \
112+
# if [ -z \"$COMMAND\" ] || [ \"$COMMAND\" = \"setup\" ]; then \
113+
# TMP_SETUP=$(mktemp -t git-enterprise-kit.XXXXXX) && \
114+
# cp \"$KIT_PATH/setup.sh\" \"$TMP_SETUP\" && \
115+
# bash \"$TMP_SETUP\" \"$KIT_PATH\" \"$@\" && \
116+
# rm \"$TMP_SETUP\"; \
117+
# elif [ \"$COMMAND\" = \"install\" ]; then \
118+
# echo \"Enterprise config already installed!\"; \
119+
# elif [ -n \"$ENV\" ] && [ -e "$KIT_PATH/envs/$ENV/$COMMAND.sh" ]; then \
120+
# bash \"$KIT_PATH/envs/$ENV/$COMMAND.sh\" \"$@\"; \
121+
# elif [ -e \"$KIT_PATH/$COMMAND.sh\" ]; then \
122+
# bash \"$KIT_PATH/$COMMAND.sh\" \"$@\"; \
123+
# else \
124+
# echo \"Enterprise Config command '$COMMAND' not found. Please contact [email protected] or the #tech-git Slack channel.\"; \
125+
# fi \
126+
# }; f"
127+
adsk = "!f() { KIT_PATH=$(dirname \"$(git config include.path)\") && ENV=$(git config adsk.environment || true) && COMMAND=$1 && if [ -n \"$COMMAND\" ]; then shift 1; fi && if [ \"$KIT_PATH\" = \"adsk-git\" ]; then case $(uname -s) in MINGW32_NT*) KIT_PATH=/mingw32/etc/adsk-git;; MINGW64_NT*) KIT_PATH=/mingw64/etc/adsk-git;; esac fi && if [ -z \"$COMMAND\" ] || [ \"$COMMAND\" = \"setup\" ]; then TMP_SETUP=$(mktemp -t git-enterprise-kit.XXXXXX) && cp \"$KIT_PATH/setup.sh\" \"$TMP_SETUP\" && bash \"$TMP_SETUP\" \"$KIT_PATH\" \"$@\" && rm \"$TMP_SETUP\"; elif [ \"$COMMAND\" = \"install\" ]; then echo \"Enterprise config already installed!\"; elif [ -n \"$ENV\" ] && [ -e "$KIT_PATH/envs/$ENV/$COMMAND.sh" ]; then bash \"$KIT_PATH/envs/$ENV/$COMMAND.sh\" \"$@\"; elif [ -e \"$KIT_PATH/$COMMAND.sh\" ]; then bash \"$KIT_PATH/$COMMAND.sh\" \"$@\"; else echo \"Enterprise Config command '$COMMAND' not found. Please contact [email protected] or the #tech-git Slack channel.\"; fi }; f"
128+
129+
130+
###############################################################################
131+
# hub command-line wrapper https://hub.github.com/
132+
###############################################################################
133+
[hub]
134+
host = git.company.com
135+
protocol = https
100136

101137

102138
###############################################################################
@@ -105,9 +141,25 @@
105141
[ghfw]
106142
disableverification = true
107143

144+
108145
###############################################################################
109146
# More helpful diff'ing of one line JSON files
110147
###############################################################################
111148
[diff "json"]
112-
textconv = "perl -MJSON::PP -e '$j = JSON::PP->new->pretty->canonical; print $j->encode($j->decode(<>))'"
149+
textconv = "perl -MJSON::PP -e '$j = JSON::PP->new->pretty->canonical; print $j->encode($j->decode(do {$/ = undef; <>}))'"
113150
cachetextconv = true
151+
152+
153+
###############################################################################
154+
# Define a merge driver that won't actually merge a file... for those files
155+
# which must never be merged.
156+
#
157+
# Example content of .gitattributes file:
158+
# branchinfo.txt merge=ours
159+
# /environment-config/* merge=ours
160+
#
161+
# Further information:
162+
# https://medium.com/@porteneuve/how-to-make-git-preserve-specific-files-while-merging-18c92343826b
163+
###############################################################################
164+
[merge "ours"]
165+
driver = true

cub.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
#/
3+
#/ Shortcut for "git $KIT_ID cleanup-branches"
4+
#/
5+
"$(dirname "$0")/cleanup-branches.sh" "$@"

download-blob.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#/
3-
#/ Download a Git object from GitHub via API.
3+
#/ Download a Git object from GitHub via API
44
#/
55
#/ Usage: git $KIT_ID download-blob [org/repo] [git-object-id]
66
#/

enable-public-push.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
#!/usr/bin/env bash
22
#/
3-
#/ Override the Enterprise Config push protection feature configure in
4-
#/ config.include.
3+
#/ Override the Enterprise Config push protection
4+
#/ feature configured in config.include.
55
#/
66
#/ Usage: git $KIT_ID enable-public-push <server/org/repo>
77
#/
88
set -e
99

1010
KIT_PATH=$(dirname "$0")
1111
. "$KIT_PATH/enterprise.constants"
12+
. "$KIT_PATH/lib/setup_helpers.sh"
13+
14+
if [ -z $1 ]; then
15+
error_exit \
16+
'A repository URL (without the "http(s)://" prefix) is required.
17+
Please try copying and pasting the command line suggested in the
18+
error message when you attempted to push to a public-facing Git
19+
service.'
20+
fi
1221

1322
REPO=$1
1423
git config --global url.https://$REPO.pushInsteadOf https://$REPO

enterprise.constants

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ KIT_SOURCE_CODE_POLICY_URL=https://yourcompany.com/policy
1515
ERROR_HELP_MESSAGE="Please contact [email protected]!"
1616

1717
# Versions
18-
INSTALL_UPGRADE_GIT_VERSION=2.14.1 # On update make sure to update strings in install-helper.ps1, too!
18+
INSTALL_UPGRADE_GIT_VERSION=2.17.0 # On update make sure to update strings in install-helper.ps1, too!
1919
MINIMUM_ADVISED_GIT_VERSION=2.13.5
20-
MINIMUM_REQUIRED_GIT_VERSION=2.3.2
20+
MINIMUM_REQUIRED_GIT_VERSION=1.8.3.1
2121

22-
MINIMUM_GIT_LFS_VERSION=2.2.1 # On update make sure to update $GIT_LFS_SHA256 in lib/*/setup_helpers.sh, too!
22+
MINIMUM_GIT_LFS_VERSION=2.3.4 # On update make sure to update $GIT_LFS_SHA256 in lib/*/setup_helpers.sh, too!

0 commit comments

Comments
 (0)