From f9247f9142f912167e16b04ae78a60d5087dbb29 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 26 Nov 2018 14:19:09 +0000 Subject: [PATCH] Add scripts for managing reviews for ONAP Change-Id: Ieccdad5ef61063c1fad88c2989edf3ce9d69dacf Signed-off-by: liamfallon --- onap-reviews/heis-clone.sh | 42 +++++++++++++++++++++ onap-reviews/heis-nordix2onap.sh | 64 ++++++++++++++++++++++++++++++++ onap-reviews/heis-pull-review.sh | 39 +++++++++++++++++++ onap-reviews/heis-push2nordix.sh | 40 ++++++++++++++++++++ 4 files changed, 185 insertions(+) create mode 100755 onap-reviews/heis-clone.sh create mode 100755 onap-reviews/heis-nordix2onap.sh create mode 100755 onap-reviews/heis-pull-review.sh create mode 100755 onap-reviews/heis-push2nordix.sh diff --git a/onap-reviews/heis-clone.sh b/onap-reviews/heis-clone.sh new file mode 100755 index 0000000..3c8fba9 --- /dev/null +++ b/onap-reviews/heis-clone.sh @@ -0,0 +1,42 @@ +#! /bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2018 The Nordix Foundation. All rights reserved. +# ================================================================================ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# +# This script clones and sets up an ONAP repository from the Nordix gerrit. It +# - clones the repository from the Nordix gerrit +# - sets up a commit hook that signs reviews when they are committed +# - sets up the ONAP gerrit as the "upstream" of the cloned repository by adding +# it as an entry to the .git/config configuration file of the repository +# + +if [ $# -ne 4 ] +then + echo "usage $0 nordix-gerrit-userid onap-gerrit-userid repository-path local-repository" + echo " example: $0 seancitizen janjansson policy/core core " + exit 1 +fi + +git clone ssh://$1@gerrit.nordix.org:29418/$3 $4 + +scp -p -P 29418 $1@gerrit.nordix.org:hooks/commit-msg $4/.git/hooks + +echo '[remote "upstream"]' >> $4/.git/config +echo " url = ssh://$2@gerrit.onap.org:29418/$3.git" >> $4/.git/config +echo " fetch = +refs/heads/*:refs/remotes/upstream/*" >> $4/.git/config diff --git a/onap-reviews/heis-nordix2onap.sh b/onap-reviews/heis-nordix2onap.sh new file mode 100755 index 0000000..cd48349 --- /dev/null +++ b/onap-reviews/heis-nordix2onap.sh @@ -0,0 +1,64 @@ +#! /bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2018 The Nordix Foundation. All rights reserved. +# ================================================================================ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# +# This script transfers a review with a given change id from the Nordix gerrit repository +# to the ONAP gerrit repository. The script: +# - switches to the master branch +# - resets the master branch to be at the latest merged version of the master branch on the +# Nordix gerrit repository +# - pulls the given review onto the master branch +# - pushes the review upstream onto the master branch of the ONAP repository +# - resets the master branch again +# - checks out the nordix-dev branch +# + +if [ $# -ne 1 ] +then + echo "usage $0 commit-id" + exit 1 +fi + +commit_check=`git log | grep "^commit $1"` +if [ "" == "$commit_check" ] +then + echo "commit with commit id $1 not found" + exit 2 +fi + +git checkout master +git fetch origin +git reset --hard origin/master + +git pull origin $1 + +git push upstream HEAD:refs/for/master +retVal=$? +if [ $retVal -eq 0 ] +then + echo "push upstream to ONAP succeeded" +else + echo "push upstream to ONAP failed" +fi + +git fetch origin +git reset --hard origin/master + +git checkout nordix-dev diff --git a/onap-reviews/heis-pull-review.sh b/onap-reviews/heis-pull-review.sh new file mode 100755 index 0000000..3d3391c --- /dev/null +++ b/onap-reviews/heis-pull-review.sh @@ -0,0 +1,39 @@ +#! /bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2018 The Nordix Foundation. All rights reserved. +# ================================================================================ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# +# This script pulls a review from the Nordix gerrit repository for rework. The script: +# - checks out the nordix-dev branch of the repository +# - resets the nordix-dev branch to be at the latest merged version of the nordix-dev branch on the +# Nordix gerrit repository +# - pulls the given review onto the master branch +# + +if [ $# -ne 1 ] +then + echo "usage $0 commit-id" + exit 1 +fi + +git checkout nordix-dev +git fetch origin +git reset --hard origin/master + +git pull origin $1 diff --git a/onap-reviews/heis-push2nordix.sh b/onap-reviews/heis-push2nordix.sh new file mode 100755 index 0000000..f30b74c --- /dev/null +++ b/onap-reviews/heis-push2nordix.sh @@ -0,0 +1,40 @@ +#! /bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2018 The Nordix Foundation. All rights reserved. +# ================================================================================ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# +# This script creates or updates a review on the Nordix gerrit repository +# + +if [ $# -ne 0 ] +then + echo "usage $0" + echo " command does not take any arguments" + exit 1 +fi + +git push origin HEAD:refs/for/nordix-dev + +retVal=$? +if [ $retVal -eq 0 ] +then + git log -1 +else + echo "push to Nordix failed" +fi -- 2.25.1