-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSS Setup #4
Merged
Merged
OSS Setup #4
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Dataline Public Repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
function _error() { | ||
echo "$@" | ||
exit 1 | ||
} | ||
|
||
function main() { | ||
[[ -e .root ]] || _error "Must run from root" | ||
|
||
git remote add oss https://github.com/datalineio/public.git | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
_usage=" | ||
Usage: ./tools/oss/push_oss.sh <target-branch> <force (optional)> | ||
Example: ./tools/oss/push_oss.sh my-branch force | ||
" | ||
|
||
function _error() { | ||
echo "$@" | ||
echo "$_usage" | ||
exit 1 | ||
} | ||
|
||
function _in_sync_with_remote() { | ||
# https://stackoverflow.com/a/3278427 | ||
git remote update | ||
UPSTREAM='@{u}' | ||
echo "checking local commit history against remote: $(git rev-parse --symbolic-full-name --abbrev-ref ${UPSTREAM})" | ||
LOCAL=$(git rev-parse @) | ||
REMOTE=$(git rev-parse "$UPSTREAM") | ||
BASE=$(git merge-base @ "$UPSTREAM") | ||
|
||
if [ $LOCAL = $REMOTE ]; then | ||
echo "Up-to-date" | ||
elif [ $LOCAL = $BASE ]; then | ||
echo "Need to pull" | ||
exit 1 | ||
elif [ $REMOTE = $BASE ]; then | ||
echo "Need to push" | ||
exit 1 | ||
else | ||
echo "Diverged" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function _on_master() { | ||
# only push master to downstream repo. | ||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
if [[ "$CURRENT_BRANCH" != "master" ]]; then | ||
_error 'Can only push to target branch master while on master branch.'; | ||
exit 1; | ||
fi | ||
} | ||
|
||
# attempts to push the public dir to the specified branch in the dataline _public_ repository. | ||
# * verifies that the branch being pushed is in sync with the origin remote of the monorepo. | ||
# * allows force push (except when pushing to master--if you need to do this, do it manually). | ||
# * only allows pushes to master from the master branch. | ||
function main() { | ||
[[ -e .root ]] || _error "Must run from root" | ||
TARGET_BRANCH=$1; shift || _error "Missing target branch" | ||
FORCE_RAW=$1; | ||
FORCE=false | ||
|
||
if [[ "$FORCE_RAW" = "force" ]]; then | ||
FORCE=true | ||
fi | ||
|
||
echo "target branch: ${TARGET_BRANCH}" | ||
echo "force: ${FORCE}" | ||
|
||
# if pushing to master on the oss repo, must push from master. | ||
if [[ "$TARGET_BRANCH" = "master" ]]; then | ||
_on_master | ||
fi | ||
|
||
if [[ "$TARGET_BRANCH" = "master" && "$FORCE" = true ]]; then | ||
_error "cannot force push to master." | ||
fi | ||
|
||
# do not push to oss repo, if local branch is not in sync with origin in monorepo. | ||
_in_sync_with_remote | ||
|
||
if [[ "$FORCE" = true ]] | ||
then | ||
git push oss `git subtree split --prefix public`:"${TARGET_BRANCH}" --force | ||
else | ||
git subtree push --prefix=public oss "${TARGET_BRANCH}" | ||
fi | ||
} | ||
|
||
main "$@" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs an exit right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. thanks.