-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-produce
More file actions
executable file
·41 lines (35 loc) · 857 Bytes
/
git-produce
File metadata and controls
executable file
·41 lines (35 loc) · 857 Bytes
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
#!/usr/bin/env bash
channel="${1}"
if [ -z "$channel" ]
then
echo "Usage: git produce <channel>"
exit 1
fi
set -eu
remote="origin"
master="main"
function update
{
git fetch $remote $channel 2> /dev/null || true
}
function checkout
{
echo "[INFO] Attempting to reuse local production branch..."
git checkout $channel 2> /dev/null || return -1
echo "[INFO] Synchronizing local production branch..."
git merge --ff-only 2> /dev/null || true
}
function create
{
echo "[INFO] Creating local production branch..."
git checkout -B $channel $master
}
echo "[INFO] Synchronizing repository..."
update
checkout || create
echo "[INFO] Merging changes from $master..."
git merge $master -m "Merge via git-produce" --ff
echo "[INFO] Pushing changes to $remote..."
git push --set-upstream $remote $channel
echo "[INFO] Cleaning up..."
git checkout $master