Uh oh!
There was an error while loading. Please reload this page.
forked from api-platform/core
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubtree.sh
More file actions
Latest commit
executable file
·43 lines (32 loc) · 861 Bytes
/
Copy pathsubtree.sh
File metadata and controls
executable file
·43 lines (32 loc) · 861 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
#!/bin/bash
set -xe
FORCE_FLAG=""
whilegetopts"f" opt;do
case$optin
f)
FORCE_FLAG="-f"
;;
\?)
echo"Invalid option: -$OPTARG">&2
exit 1
;;
esac
done
shift$((OPTIND-1))
# The first argument is now the path to composer.json
COMPOSER_JSON_PATH=$1
# The second argument is the git ref
GIT_REF=$2
if [ -z"$COMPOSER_JSON_PATH" ] || [ -z"$GIT_REF" ];then
echo"Usage: $0 [-f] <path-to-composer.json> <git-ref>"
exit 1
fi
package=$(jq -r .name "$COMPOSER_JSON_PATH")
directory=$(dirname "$COMPOSER_JSON_PATH")
repository="https://github.com/$package"
# Add the remote only if it doesn't exist already
if! git remote get-url "$package"> /dev/null 2>&1;then
git remote add "$package""$repository"
fi
sha=$(splitsh-lite --prefix="$directory")
git push $FORCE_FLAG"$package""$sha":"$GIT_REF"