Skip to content

Commit fb400f1

Browse files
committed
IGNITE-14518 Add proper license and long description to package info - Fixes #31.
1 parent 3586db7 commit fb400f1

File tree

3 files changed

+371
-1
lines changed

3 files changed

+371
-1
lines changed

scripts/apply_pull_request.sh

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
#
20+
# Pull request applier.
21+
#
22+
23+
#
24+
# Start of Functions.
25+
#
26+
27+
#
28+
# Prints usage.
29+
#
30+
usage () {
31+
echo 'Usage: scripts/apply-pull-request.sh <pull-request-id> [-tb|--targetbranch <branch-name>] [--with-gpg] [-s|--sign-off]'
32+
echo 'The script takes pull-request by given id and merges (with squash) all changes to target branch (master by default).'
33+
echo "Argument 'pull-request-id' is mandatory."
34+
echo "Target branch can be overwritten by using [-tb|--targetbranch <branch-name>] argument paramethers."
35+
}
36+
37+
#
38+
# End of Functions.
39+
#
40+
41+
if [ "${GIT_HOME}" = "" ]; then
42+
GIT_HOME="$(dirname "$(cd "$(dirname "$0")"; "pwd")")";
43+
fi
44+
45+
cd "${GIT_HOME}" || { echo "failed to change director ${GIT_HOME}"; exit 1; }
46+
47+
if [ "${SCRIPTS_HOME}" = "" ]; then
48+
SCRIPTS_HOME="${GIT_HOME}/scripts/"
49+
fi
50+
51+
. "${SCRIPTS_HOME}"/git_patch_functions.sh # Import patch functions.
52+
53+
PR_ID=$1
54+
55+
#
56+
# Start reading of command line params.
57+
#
58+
if [ "${PR_ID}" = "" ]; then
59+
echo "$0, ERROR:"
60+
echo >&2 "You have to specify 'pull-request-id'."
61+
echo
62+
usage
63+
exit 1
64+
fi
65+
66+
if [ "${PR_ID}" = "-h" ]; then
67+
usage
68+
exit 0
69+
fi
70+
71+
if [ "${PR_ID}" = "--help" ]; then
72+
usage
73+
exit 0
74+
fi
75+
76+
77+
while [[ $# -ge 2 ]]
78+
do
79+
key="$2"
80+
81+
case $key in
82+
-tb|--targetbranch)
83+
TARGET_BRANCH="$3"
84+
shift 2
85+
;;
86+
87+
--with-gpg)
88+
WITH_GPG="true"
89+
shift
90+
;;
91+
92+
-s|--sign-off)
93+
WITH_SIGN_OFF="true"
94+
shift
95+
;;
96+
97+
*)
98+
echo "Unknown parameter: ${key}"
99+
echo
100+
usage
101+
exit 1
102+
;;
103+
esac
104+
done
105+
#
106+
# Enf reading of command line params.
107+
#
108+
109+
110+
# Script variables.
111+
if [ "${APACHE_GIT}" = "" ]; then
112+
APACHE_GIT="https://gitbox.apache.org/repos/asf/ignite-python-thin-client.git"
113+
fi
114+
115+
if [ "${GITHUB_MIRROR}" = "" ]; then
116+
GITHUB_MIRROR="[email protected]:apache/ignite-python-thin-client.git"
117+
fi
118+
119+
if [ "${TARGET_BRANCH}" = "" ]; then
120+
TARGET_BRANCH="master"
121+
fi
122+
123+
requireCleanWorkTree "${GIT_HOME}"
124+
125+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
126+
127+
if [ "$CURRENT_BRANCH" != "${TARGET_BRANCH}" ]; then
128+
echo "$0, ERROR:"
129+
echo "You have to be on ${TARGET_BRANCH} branch."
130+
131+
exit 1
132+
fi
133+
134+
# Check that target branch is up-to-date.
135+
APACHE_GIT_TARGET_BRANCH="apache-git-target-br-tmp"
136+
137+
git fetch ${APACHE_GIT} ${TARGET_BRANCH}:${APACHE_GIT_TARGET_BRANCH} &> /dev/null
138+
if test $? != 0; then
139+
echo "$0, ERROR:"
140+
echo >&2 "Couldn't fetch '${TARGET_BRANCH}' branch from ${APACHE_GIT}."
141+
exit 1
142+
fi
143+
144+
LOCAL_TARGET_BR_HASH=$(git rev-parse @)
145+
REMOTE_TARGET_BR_HASH=$(git rev-parse ${APACHE_GIT_TARGET_BRANCH})
146+
BASE_HASH=$(git merge-base @ ${APACHE_GIT_TARGET_BRANCH})
147+
148+
git branch -D ${APACHE_GIT_TARGET_BRANCH} &> /dev/null
149+
150+
if [ "$LOCAL_TARGET_BR_HASH" != "$REMOTE_TARGET_BR_HASH" ]; then
151+
echo "$0, ERROR:"
152+
153+
if [ "$LOCAL_TARGET_BR_HASH" = "$BASE_HASH" ]; then
154+
echo "Your local ${TARGET_BRANCH} branch is not up-to-date. You need to pull."
155+
elif [ "$REMOTE_TARGET_BR_HASH" = "$BASE_HASH" ]; then
156+
echo "Your local ${TARGET_BRANCH} branch is ahead of ${TARGET_BRANCH} branch at Apache git. You need to push."
157+
else
158+
echo "Your local ${TARGET_BRANCH} and Apache git ${TARGET_BRANCH} branches diverged. You need to pull, merge and pull."
159+
fi
160+
161+
exit 1
162+
fi
163+
164+
echo "Local ${TARGET_BRANCH} is Up-to-date."
165+
echo
166+
167+
# Checkout pull-request branch.
168+
PR_BRANCH_NAME="pull-${PR_ID}-head"
169+
170+
git fetch "${GITHUB_MIRROR}" "pull/${PR_ID}/head:${PR_BRANCH_NAME}" &> /dev/null
171+
if test $? != 0; then
172+
echo "$0, ERROR:"
173+
echo >&2 "There was not found pull request by ID = '${PR_ID}'."
174+
exit 1
175+
fi
176+
177+
# Get author name number.
178+
git checkout "${PR_BRANCH_NAME}" &> /dev/null
179+
if test $? != 0; then
180+
echo "$0, ERROR:"
181+
echo >&2 "Failed to checkout '${PR_BRANCH_NAME}' branch (the branch not found or already exists)."
182+
exit 1
183+
fi
184+
185+
AUTHOR="$(git --no-pager show -s --format="%aN <%aE>" HEAD)"
186+
ORIG_COMMENT="$(git log -1 --pretty=%B)"
187+
188+
echo "Author of pull-request: '$AUTHOR'."
189+
echo
190+
191+
# Update local target branch.
192+
git checkout ${TARGET_BRANCH} &> /dev/null
193+
194+
# Take changes.
195+
git merge --squash "${PR_BRANCH_NAME}" &> /dev/null
196+
if test $? != 0; then
197+
git reset --hard &> /dev/null
198+
199+
echo "$0, ERROR:"
200+
echo >&2 "Could not merge the pull-request to ${TARGET_BRANCH} without conflicts. All local changes have been discarded. You're on ${TARGET_BRANCH} branch."
201+
exit 1
202+
fi
203+
204+
echo "Original comment is"
205+
echo "\"${ORIG_COMMENT}\""
206+
echo "Press [ENTER] if you're agree with the comment or type your comment and press [ENTER]:"
207+
read -r COMMENT
208+
echo
209+
210+
if [ "${COMMENT}" == "" ]; then
211+
COMMENT=${ORIG_COMMENT}
212+
fi
213+
214+
COMMENT="${COMMENT} - Fixes #${PR_ID}."
215+
216+
if [ "${EXCLUDE_SPECIAL_FILE}" = "true" ]; then
217+
git checkout HEAD ignite-pull-request-id
218+
fi
219+
220+
SIGN_OPTION=""
221+
if [ -n "${WITH_GPG}" ]; then
222+
SIGN_OPTION="-S"
223+
fi
224+
225+
if [ -n "${WITH_SIGN_OFF}" ]; then
226+
SIGN_OPTION="${SIGN_OPTION} -s"
227+
fi
228+
229+
git commit --author "${AUTHOR}" -a ${SIGN_OPTION} -m "${COMMENT}" &> /dev/null
230+
231+
echo "Squash commit for pull request with id='${PR_ID}' has been added. The commit has been added with comment '${COMMENT}'."
232+
echo "Now you can review changes of the last commit at ${TARGET_BRANCH} and push it into ${APACHE_GIT} git after."
233+
echo "If you want to decline changes, you can remove the last commit from your repo by 'git reset --hard HEAD^'."
234+
echo
235+
236+
# Clean-up.
237+
git branch -D "${PR_BRANCH_NAME}" &> /dev/null
238+
239+
echo 'Successfully completed.'

scripts/git_patch_functions.sh

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
#
20+
# Git patch functions.
21+
#
22+
23+
#
24+
# Define functions.
25+
#
26+
27+
#
28+
# Formats patch. Create patch in one commit from user who run script and with default comment.
29+
#
30+
# Params:
31+
# - Git home.
32+
# - Default branch.
33+
# - Patch with patch.
34+
# - Suffix for created patch-file.
35+
#
36+
formatPatch () {
37+
GIT_HOME=$1
38+
DEFAULT_BRANCH=$2
39+
PATCHED_BRANCH=$3
40+
PATCH_SUFFIX=$4
41+
42+
if [ "${IGNITE_CURRENT_BRANCH}" = "${IGNITE_DEFAULT_BRANCH}" ]
43+
then
44+
echo "$0, ERROR:"
45+
echo "You are on Default branch. Please, checkout branch with changes."
46+
47+
exit 1
48+
fi
49+
50+
cd "${GIT_HOME}" || { echo "failed to change directory to ${GIT_HOME}"; exit 1; }
51+
52+
git checkout "${DEFAULT_BRANCH}"
53+
54+
DEF_BRANCH_REV="$(git rev-parse --short HEAD)"
55+
56+
git checkout -b tmppatch
57+
58+
# Merge to make only one commit.
59+
git merge --squash ${PATCHED_BRANCH}
60+
git commit -a -m "# ${PATCHED_BRANCH}"
61+
62+
PATCH_FILE=${PATCHES_HOME}'/'${DEFAULT_BRANCH}_${DEF_BRANCH_REV}_${PATCHED_BRANCH}${PATCH_SUFFIX}
63+
64+
git format-patch ${DEFAULT_BRANCH} --stdout > ${PATCH_FILE}
65+
echo "Patch file created."
66+
67+
git checkout ${PATCHED_BRANCH}
68+
69+
git branch -D tmppatch # Delete tmp branch.
70+
71+
echo
72+
echo "Patch created: ${PATCH_FILE}"
73+
}
74+
75+
#
76+
# Determines Current branch.
77+
#
78+
# Params:
79+
# - Git home.
80+
# Return - Current branch.
81+
#
82+
determineCurrentBranch () {
83+
GIT_HOME=$1
84+
85+
cd ${GIT_HOME} || { echo "failed to change directory to $1"; exit 1; }
86+
87+
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
88+
89+
echo "$CURRENT_BRANCH"
90+
}
91+
92+
#
93+
# Checks that given git repository has clean work tree (there is no uncommited changes).
94+
# Exit with code 1 in error case.
95+
#
96+
# Params:
97+
# - Git home.
98+
#
99+
requireCleanWorkTree () {
100+
cd "$1" || { echo "failed to change directory to $1"; exit 1; } # At git home.
101+
102+
# Update the index
103+
git update-index -q --ignore-submodules --refresh
104+
err=0
105+
106+
# Disallow unstaged changes in the working tree
107+
if ! git diff-files --quiet --ignore-submodules --
108+
then
109+
echo "$0, ERROR:"
110+
echo >&2 "You have unstaged changes."
111+
git diff-files --name-status -r --ignore-submodules -- >&2
112+
err=1
113+
fi
114+
115+
# Disallow uncommitted changes in the index
116+
if ! git diff-index --cached --quiet HEAD --ignore-submodules --
117+
then
118+
echo "$0, ERROR:"
119+
echo >&2 "Your index contains uncommitted changes."
120+
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
121+
err=1
122+
fi
123+
124+
if [ $err = 1 ]
125+
then
126+
echo >&2 "Please commit or stash them."
127+
exit 1
128+
fi
129+
}

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def is_a_requirement(line):
8686
with open('README.md', 'r', encoding='utf-8') as readme_file:
8787
long_description = readme_file.read()
8888

89-
version = ''
9089
with open('pyignite/__init__.py', 'r') as fd:
9190
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
9291
fd.read(), re.MULTILINE).group(1)
@@ -111,6 +110,8 @@ def run_setup(with_binary=True):
111110
author='The Apache Software Foundation',
112111
author_email='[email protected]',
113112
description='Apache Ignite binary client Python API',
113+
long_description=long_description,
114+
long_description_content_type='text/markdown',
114115
url='https://github.com/apache/ignite-python-thin-client',
115116
packages=setuptools.find_packages(),
116117
install_requires=requirements['install'],
@@ -119,6 +120,7 @@ def run_setup(with_binary=True):
119120
extras_require={
120121
'docs': requirements['docs'],
121122
},
123+
license="Apache License 2.0",
122124
classifiers=[
123125
'Programming Language :: Python',
124126
'Programming Language :: Python :: 3',

0 commit comments

Comments
 (0)