Skip to content

Commit 9fa9d72

Browse files
committed
update ruby wrapper
1 parent 0e82c2c commit 9fa9d72

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

git_push.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
#
3+
# Generated by: https://github.com/swagger-api/swagger-codegen.git
4+
#
5+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
6+
#
7+
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
8+
9+
git_user_id=$1
10+
git_repo_id=$2
11+
release_note=$3
12+
13+
if [ "$git_user_id" = "" ]; then
14+
git_user_id="GIT_USER_ID"
15+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
16+
fi
17+
18+
if [ "$git_repo_id" = "" ]; then
19+
git_repo_id="GIT_REPO_ID"
20+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
21+
fi
22+
23+
if [ "$release_note" = "" ]; then
24+
release_note="Minor update"
25+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
26+
fi
27+
28+
# Initialize the local directory as a Git repository
29+
git init
30+
31+
# Adds the files in the local repository and stages them for commit.
32+
git add .
33+
34+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
35+
git commit -m "$release_note"
36+
37+
# Sets the new remote
38+
git_remote=`git remote`
39+
if [ "$git_remote" = "" ]; then # git remote not defined
40+
41+
if [ "$GIT_TOKEN" = "" ]; then
42+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
43+
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
44+
else
45+
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
46+
fi
47+
48+
fi
49+
50+
git pull origin master
51+
52+
# Pushes (Forces) the changes in the local repository up to the remote repository
53+
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
54+
git push origin master 2>&1 | grep -v 'To https'
55+

0 commit comments

Comments
 (0)