-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
wpgit
executable file
·53 lines (44 loc) · 1.29 KB
/
wpgit
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
50
51
52
53
#!/bin/bash
#
# Check out a common git repository of WordPress
#
# VERSION :0.2.0
# DATE :2015-08-17
# AUTHOR :Viktor Szépe <viktor@szepe.net>
# LICENSE :The MIT License (MIT)
# URL :https://github.com/szepeviktor/debian-server-tools
# BASH-VERSION :4.2+
# DOCS :https://git-scm.com/blog/2011/07/11/reset.html
# DEPENDS :apt-get install git
# ORIGIN :https://github.com/WordPress/WordPress.git
# LOCATION :/usr/local/bin/wpgit
# Usage
#
# Check out tag 4.2.4
#
# wpgit 4.2.4
#
# Display current status (like `wp core verify-checksums`)
#
# wpgit
export GIT_DIR="/usr/local/src/wordpress.git"
if [ $# == 1 ]; then
TAG="$1"
# Update HEAD and index only
git fetch --prune --tags origin master
ORIGIN_LATEST_COMMIT="$(git rev-list origin/master | head -n 1)"
git reset "$ORIGIN_LATEST_COMMIT"
# Check tag
if ! git rev-parse --verify --quiet "$TAG" > /dev/null; then
echo "ERROR: $?, last 20 tags: $(git tag | tail -n 20 | paste -s -d " ")" 1>&2
exit 1
fi
# Update working tree
git checkout "$TAG" -- .
fi
# @WIP
# Show differences from a given tag
#TAG_COMMIT="$(git rev-list "$TAG" | head -n 1)"
#git diff "${TAG_COMMIT}^1" -- .
# Show untracked files
#git status --short | grep "^? "