-
Couldn't load subscription status.
- Fork 17
ENH: Migrate Gerrit to GitHub hooks #49
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
Merged
thewtex
merged 1 commit into
InsightSoftwareConsortium:master
from
thewtex:github-client-hooks
Feb 7, 2018
Merged
Changes from all commits
Commits
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
This file contains hidden or 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,25 @@ | ||
| #========================================================================== | ||
| # | ||
| # Copyright Insight Software Consortium | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0.txt | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| #==========================================================================*/ | ||
|
|
||
| # Loaded by .git/hooks/(pre-commit|commit-msg|prepare-commit-msg) | ||
| # during git commit after local hooks have been installed. | ||
|
|
||
| hooks_chain_pre_commit="Utilities/Hooks/pre-commit" | ||
| hooks_chain_commit_msg="Utilities/Hooks/commit-msg" | ||
| hooks_chain_prepare_commit_msg="Utilities/Hooks/prepare-commit-msg" | ||
| #hooks_chain_post_commit="Utilities/Hooks/post-commit" |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| [hooks] | ||
| url = http://public.kitware.com/GitSetup.git | ||
| [gerrit] | ||
| project = ITKSoftwareGuide | ||
| site = http://review.source.kitware.com | ||
| pushurl = $username@review.source.kitware.com:ITKSoftwareGuide | ||
| [upstream] | ||
| url = https://github.com/InsightSoftwareConsortium/ITKSoftwareGuide.git | ||
| remote = upstream | ||
| [github] | ||
| organization-name = InsightSoftwareConsortium | ||
| repo-name = ITKSoftwareGuide |
This file contains hidden or 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,38 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| usage() { | ||
| echo "git pr <pull-request-number>" | ||
| } | ||
|
|
||
| if [[ "$1" = "-h" || "$1" = "--help" ]] ; then | ||
| usage | ||
| exit 0 | ||
| fi | ||
|
|
||
|
|
||
| if [[ $# -lt 1 ]]; then | ||
| if type python3 >/dev/null 2>&1 && type curl >/dev/null 2>&1; then | ||
| config="${BASH_SOURCE%/*}/config" && | ||
| host=$(git config -f "$config" --get github.host || echo "github.com") | ||
| organization_name=$(git config -f "$config" --get github.organization-name) | ||
| repo_name=$(git config -f "$config" --get github.repo-name) | ||
| url="https://api.$host/repos/$organization_name/$repo_name/pulls?sort=updated;direction=desc" | ||
| pr_prompt=$(curl -s "https://api.$host/repos/$organization_name/$repo_name/pulls?sort=updated;direction=desc" \ | ||
| | python3 -c "import sys, json; res = json.load(sys.stdin); [print(str(pr['number']) + ': ' + pr['title']) for pr in res];") | ||
| echo "$pr_prompt" | ||
| echo "" | ||
| pr_number=$(echo "$pr_prompt" | sed -n -e "s/\([[:alnum:]]\+\).*/\1/p" | tail -n1) | ||
| read -ep "Pull request number? [$pr_number]: " ans && | ||
| if [ -n "$ans" ]; then | ||
| pr_number="$ans" | ||
| fi | ||
| else | ||
| usage | ||
| exit 1 | ||
| fi | ||
| else | ||
| pr_number=$1 | ||
| fi | ||
|
|
||
| git fetch -fu ${2:-upstream} refs/pull/$pr_number/head:pr/$pr_number && \ | ||
| git checkout pr/$pr_number; |
This file contains hidden or 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,97 @@ | ||
| #!/usr/bin/env bash | ||
| #============================================================================= | ||
| # Copyright 2010-2012 Kitware, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| #============================================================================= | ||
|
|
||
| USAGE="[<remote>] [--no-topic] [--dry-run] [--]" | ||
| OPTIONS_SPEC= | ||
| SUBDIRECTORY_OK=Yes | ||
| . "$(git --exec-path)/git-sh-setup" | ||
|
|
||
| # Load the project configuration. | ||
| config="${BASH_SOURCE%/*}/config" && | ||
| upstream_remote=$(git config -f "$config" --get upstream.remote) && | ||
| host=$(git config -f "$config" --get github.host || echo "github.com") && | ||
| organization_name=$(git config -f "$config" --get github.organization-name) && | ||
| repo_name=$(git config -f "$config" --get github.repo-name) | ||
| github_remote=$(git config --get github.fork.remote) | ||
| #----------------------------------------------------------------------------- | ||
|
|
||
| remote="$github_remote" | ||
| refspecs='' | ||
| no_topic='' | ||
| dry_run='' | ||
| force='' | ||
|
|
||
| # Parse the command line options. | ||
| while test $# != 0; do | ||
| case "$1" in | ||
| --no-topic) no_topic=1 ;; | ||
| --force) force=--force ;; | ||
| --dry-run) dry_run=--dry-run ;; | ||
| --) shift; break ;; | ||
| -*) usage ;; | ||
| *) test -z "$remote" || usage ; remote="$1" ;; | ||
| esac | ||
| shift | ||
| done | ||
| test $# = 0 || usage | ||
|
|
||
| # Default remote. | ||
| test -n "$remote" || remote="origin" | ||
|
|
||
| if test -z "$no_topic"; then | ||
| # Identify and validate the topic branch name. | ||
| topic="$(git symbolic-ref HEAD | sed -e 's|^refs/heads/||')" | ||
| if test "$topic" = "master"; then | ||
| die 'Please name your topic: | ||
| git checkout -b descriptive-name' | ||
| fi | ||
| refspecs="HEAD:$topic" | ||
| fi | ||
|
|
||
| # Exit early if we have nothing to push. | ||
| if test -z "$refspecs"; then | ||
| echo "Nothing to push!" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Fetch the current upstream master branch head. | ||
| # This helps the computation of a minimal pack to push. | ||
| if test -z "$upstream_remote"; then | ||
| echo "Fetching $upstream_remote master" | ||
| fetch_out=$(git fetch "$upstream_remote" master 2>&1) || die "$fetch_out" | ||
| fi | ||
|
|
||
| # Push. Save output and exit code. | ||
| echo "Pushing to $remote" | ||
| push_stdout=$(git push --porcelain $force $dry_run "$remote" $refspecs); push_exit=$? | ||
| echo "$push_stdout" | ||
|
|
||
| if test $push_exit; then | ||
| topic="$(git symbolic-ref HEAD | sed -e 's|^refs/heads/||')" | ||
| pushurl="$(git config --get remote."$remote".pushurl)" | ||
| username=$(echo $pushurl | sed -n -e "s/git@$host:\([[:alnum:]]\+\).*/\1/p") | ||
| if test -n "$username"; then | ||
| echo ' | ||
| Preview the pull request by visiting: | ||
|
|
||
| https://'"$host"'/'"$organization_name"'/'"$repo_name"'/compare/master...'"$username"':'"$topic"' | ||
| ' | ||
| fi | ||
| fi | ||
|
|
||
| # Reproduce the push exit code. | ||
| exit $push_exit |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 | ||
|
|
||
| # Alias to checkout a pull request by its numerical id | ||
| git config alias.pr "!bash Utilities/GitSetup/git-pr" | ||
| # Remove previously checked out pull request | ||
| git config alias.pr-clean '!git checkout master ; git for-each-ref refs/heads/pr/* --format="%(refname)" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done' | ||
|
|
||
| # Alias to push the current topic branch to GitHub | ||
| git config alias.review-push "!bash Utilities/GitSetup/git-review-push" | ||
|
|
||
| git config alias.gerrit-push \ | ||
| "!bash -c 'echo \\\"git gerrit-push\\\" is deprecated. Please use \\\"git review-push\\\" instead.'" | ||
|
|
||
| # Useful alias to see what commits are on the current branch with respect to | ||
| # upstream/master | ||
| git config alias.prepush 'log --graph --stat upstream/master..' | ||
Oops, something went wrong.
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.
Is this
gerritalias still necessary?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 is to help transition for folks with old documentation or habits.
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.
OK.