Last active
December 31, 2020 17:27
-
-
Save jcfr/3fd1bfddafb954989a4043e3b0ed7161 to your computer and use it in GitHub Desktop.
Since the project `pytest-plugins` contains multiple independent python projects, it is not directly pip-installable. This is problematic when upstream maintainers have not yet created a new release and a project wants to depends on the latest version of some of the project. As a workaround, this script allows to *force* push to $REPO a branch f…
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
#!/usr/bin/env bash | |
REPO=git@github.com:jcfr/pytest-plugins.git | |
#UPSTREAM_REPO=git://github.com/manahl/pytest-plugins.git | |
UPSTREAM_REPO=$REPO | |
UPSTREAM_BRANCH=fix-virtualenv-installed-package-on-windows | |
PACKAGES="pytest-virtualenv" | |
# Since the project `pytest-plugins` contains multiple independent | |
# python projects, it is not directly pip-installable. | |
# | |
# This is problematic when upstream maintainers have not yet created | |
# a new release and a project wants to depends on the latest version | |
# of some of the project. | |
# | |
# As a workaround, this script allows to *force* push to $REPO a | |
# branch for each project. Each branch will contain all the sources | |
# required to pip install the project. | |
# | |
# Usage: | |
# | |
# mkdir ~/scratch && cd scratch | |
# ./pytest-plugins-pip-installable-master.sh | |
# | |
COPY_FILES="VERSION CHANGES.md common_setup.py MANIFEST.in" | |
rm -rf pytest-plugins | |
git clone $REPO | |
# Fetch latest version | |
pushd pytest-plugins | |
git remote add upstream $UPSTREAM_REPO && \ | |
git fetch upstream && \ | |
git reset --hard upstream/$UPSTREAM_BRANCH && \ | |
UPSTREAM_REPO_SHA=$(git rev-parse --short=7 HEAD) | |
UPSTREAM_REPO_DATE=$(git show -s --format=%ci $UPSTREAM_REPO_SHA | cut -f1 -d" ") | |
popd | |
for package in $PACKAGES; do | |
pushd pytest-plugins | |
# Copy common file to project directory | |
for file in $COPY_FILES; do cp $file $package/; done | |
popd | |
# Copy project into its own directory | |
rm -rf $package | |
cp -r pytest-plugins/$package $package && \ | |
cp -r pytest-plugins/.git $package/.git | |
# Push a branch for each independent project | |
pushd $package | |
git checkout -b $package-$UPSTREAM_REPO_DATE-$UPSTREAM_REPO_SHA && \ | |
git add -A && \ | |
git commit -m "Relocate $package to allow install from requirements.txt | |
This commit was automatically created by https://gist.github.com/jcfr/19a360f541b5caae5f31ac31c83e4f65 | |
It is based of: | |
* repository: $UPSTREAM_REPO | |
* branch: $UPSTREAM_BRANCH | |
* commit: $UPSTREAM_REPO_SHA | |
* date: $UPSTREAM_REPO_DATE | |
" && \ | |
git push origin $package-$UPSTREAM_REPO_DATE-$UPSTREAM_REPO_SHA --force | |
popd | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment