-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-push
50 lines (41 loc) · 1.12 KB
/
pre-push
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
48
49
#!/bin/bash
## the platform-sync container performs
## the required actions to post metadata
if [[ "$TOOL_PACKAGE" == "anaconda-platform-sync" ]]; then
exit 0
fi
PYTHON=/opt/continuum/anaconda/envs/lab_launch/bin/python
OCS=/opt/continuum/scripts
HAS_TAGS=0
DRY_RUN=""
VERBOSE=""
## process git push
push_command=$(ps -ocommand= -p $PPID)
with_tags="^(--tags|--follow-tags)"
is_dry_run="^(--dry-run|-n)"
is_destructive='^(--force|--delete|-f|-d)'
is_verbose="^(--verbose|-v)"
for arg in $push_command; do
if [[ $arg =~ $is_destructive ]]; then
echo "Force push and delete are disabled. You may wish to use 'git revert' instead."
exit 1
fi
if [[ $arg =~ $is_dry_run ]]; then
DRY_RUN="--dry-run"
fi
if [[ $arg =~ $is_verbose ]]; then
VERBOSE="-v"
fi
if [[ $arg =~ $with_tags ]]; then
HAS_TAGS=1
fi
done
### AE5 cannot accept annotated tags, rewrite them before allowing git push
$PYTHON $OCS/retag.py $DRY_RUN $VERBOSE
if [ "$HAS_TAGS" -eq "1" ]; then
## silent exit on git push --tags
exit 0
else
$PYTHON $OCS/pre-push.py $DRY_RUN $VERBOSE
git push --no-verify --tags $DRY_RUN $VERBOSE
fi