Skip to content

Commit b998f57

Browse files
authored
Update slice.sh
make heneric slices
1 parent c31da79 commit b998f57

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

slice.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
#!/bin/bash
2-
cd minetest_game
3-
git subtree split -P mods/$1 -b $1
4-
git push "https://x-access-token:${access_token}@github.com/minetest-game/${1}.git" ${1}:master
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
_git_subtree_branch_prefix="___"
6+
_git_branch="$(git rev-parse --abbrev-ref HEAD)"
7+
GITHUB_OWNER="${GITHUB_REPOSITORY%%/*}"
8+
9+
for _i in "${@}" ; do
10+
11+
[ -e "${_i}" ] || continue
12+
13+
_dir="${_i}"
14+
_basename="$(basename "${_i}")"
15+
16+
git subtree split -P "${_dir}" -b "${_git_subtree_branch_prefix}${_basename}" \
17+
|| exit 1
18+
19+
done
20+
21+
readarray -t _git_branches < <(git branch --list "${_git_subtree_branch_prefix}*")
22+
23+
for _i in "${_git_branches}" ; do
24+
25+
_git_subtree_branch="${_i}"
26+
_git_remote_repo_name="${_git_subtree_branch#${_git_subtree_branch_prefix}}"
27+
git push "https://x-access-token:${ACCESS_TOKEN}@github.com/${GITHUB_OWNER}/${_git_remote_repo_name}.git" "${_git_subtree_branch}:${_git_branch}"
28+
29+
done

0 commit comments

Comments
 (0)