diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 00000000..38360284 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,23 @@ +name: Rebase + +on: + workflow_dispatch: + schedule: + - cron: '0 */12 * * *' + +jobs: + rebase: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: git config user.name "$(git log -1 --pretty=format:'%aN')" + - run: git config user.email "$(git log -1 --pretty=format:'%aE')" + - run: git fetch --prune --unshallow origin +refs/tags/*:refs/tags/* + - run: git fetch https://github.com/stacked-git/stgit.git master + - run: git rebase FETCH_HEAD + - name: Push changes + uses: ad-m/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + force: true diff --git a/Makefile b/Makefile index 8e2c8400..252ed6c2 100644 --- a/Makefile +++ b/Makefile @@ -35,13 +35,13 @@ install-html: lint: lint-black lint-isort lint-flake8 lint-t lint-black: - $(PYTHON) -m black --check --quiet --diff . stg + $(PYTHON) -m black --check --quiet --diff . lint-isort: - $(PYTHON) -m isort --check-only --quiet --diff . stg + $(PYTHON) -m isort --check-only --quiet --diff . lint-flake8: - $(PYTHON) -m flake8 . stg + $(PYTHON) -m flake8 . lint-t: $(MAKE) -C t test-lint @@ -49,18 +49,18 @@ lint-t: .PHONY: lint lint-black lint-isort lint-flake8 lint-t format: - $(PYTHON) -m black . stg - $(PYTHON) -m isort --quiet . stg + $(PYTHON) -m black . + $(PYTHON) -m isort --quiet . test: build $(MAKE) -C t all test-patches: - for patch in $$(stg series --noprefix $(TEST_PATCHES)); do \ - stg goto $$patch && $(MAKE) test || break; \ + for patch in $$(t/stg series --noprefix $(TEST_PATCHES)); do \ + t/stg goto $$patch && $(MAKE) test || break; \ done -.PHONY: format test test-patches +.PHONY: format test test-patches .install coverage: $(MAKE) coverage-test @@ -71,10 +71,11 @@ coverage-test: $(MAKE) .coverage .coverage: - rm -rf build + rm -rf install + $(MAKE) build -mkdir .cov-files COVERAGE_FILE=$(CURDIR)/.cov-files/.coverage \ - $(PYTHON) -m coverage run --context=setup setup.py build + $(PYTHON) -m coverage run --context=setup setup.py install COVERAGE_PROCESS_START=$(CURDIR)/pyproject.toml \ COVERAGE_FILE=$(CURDIR)/.cov-files/.coverage \ $(MAKE) -C t all @@ -101,6 +102,7 @@ clean: $(MAKE) -C $$dir clean; \ done rm -rf build + rm -rf inst rm -rf dist rm -f stgit/*.pyc rm -rf stgit/__pycache__ diff --git a/README.md b/README.md index 3f9686fb..07b8d7d8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # Stacked Git +[![Build](https://github.com/wildmichael/stgit/actions/workflows/ci.yml/badge.svg)](https://github.com/wildmichael/stgit/actions/workflows/ci.yml) +[![Rebase](https://github.com/wildmichael/stgit/actions/workflows/rebase.yml/badge.svg)](https://github.com/wildmichael/stgit/actions/workflows/rebase.yml) + +> ## Note +> This is a fork where I maintain a few modifications to the upstream source. +> Once I consider them to be ready, I'll submit them as pull requests +> for inclusion in the upstream sources. + Stacked Git, **StGit** for short, is an application for managing Git commits as a stack of patches. diff --git a/setup.py b/setup.py index 341cf24a..e2b938f6 100755 --- a/setup.py +++ b/setup.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 import os import sys -from distutils.core import setup from glob import glob +from setuptools import setup + from stgit import commands, version from stgit.completion.bash import write_bash_completion from stgit.completion.fish import write_fish_completion @@ -110,7 +111,9 @@ def __check_git_version(): download_url='https://github.com/stacked-git/stgit.git', description='Stacked Git', long_description='Application for managing Git commits as a stack of patches.', - scripts=['stg'], + entry_points={ + 'console_scripts': ['stg=stgit.main:main'], + }, packages=[ 'stgit', 'stgit.commands', diff --git a/stg b/stg deleted file mode 100755 index a2d760b7..00000000 --- a/stg +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 -import os -import sys - -__copyright__ = """ -Copyright (C) 2005, Catalin Marinas - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, see http://www.gnu.org/licenses/. -""" - -if __name__ == '__main__': - if sys.version_info[:2] < (3, 5): - sys.stderr.write('StGit requires Python >= 3.5\n') - sys.exit(1) - - if os.environ.get('COVERAGE_PROCESS_START'): - import sys - - import coverage - - if len(sys.argv) < 2 or sys.argv[1].startswith('-'): - context = 'stg' - else: - context = 'stg-' + sys.argv[1] - - cov = coverage.process_startup() - cov.switch_context(context) - - from stgit.main import main - - main() diff --git a/stgit/main.py b/stgit/main.py index 7a94993b..f0280996 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -206,7 +206,28 @@ def _main(): def main(): + import sys + try: + if sys.version_info[:2] < (3, 5): + sys.stderr.write('StGit requires Python >= 3.5\n') + sys.exit(1) + + if os.environ.get('COVERAGE_PROCESS_START'): + import coverage + + if len(sys.argv) < 2 or sys.argv[1].startswith('-'): + context = 'stg' + else: + context = 'stg-' + sys.argv[1] + + cov = coverage.process_startup() + cov.switch_context(context) + _main() finally: run.finish_logging() + + +if __name__ == '__main__': + main() diff --git a/t/stg b/t/stg new file mode 100755 index 00000000..e19c317c --- /dev/null +++ b/t/stg @@ -0,0 +1,22 @@ +#!/bin/sh + +# This script is only used by the tests so they can work without stgit being +# installed. It assumes PYTHONPATH to be set up correctly. + +CUR_DIR="$(pwd)" +SCRIPT_DIR="$(dirname "$0")" +cd "$SCRIPT_DIR" +SCRIPT_DIR="$(pwd)" +cd "$CUR_DIR" +STGIT_ROOT="$(realpath "$SCRIPT_DIR/..")" + +# sanity check +if test ! -f "$STGIT_ROOT/build/lib/stgit/main.py"; then + echo >&2 "error: $STGIT_ROOT/build/lib/stgit/main.py missing (has stg been built?)." + exit 1 +fi + +PYTHON="${PYTHON:-python}" +export PYTHONPATH="$STGIT_ROOT/build/lib" + +"$PYTHON" -m stgit.main "$@" diff --git a/t/test-lib.sh b/t/test-lib.sh index 3158b1ab..e51e3ac9 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -37,16 +37,13 @@ then fi STG_ROOT=$(cd "$TEST_DIRECTORY"/.. && pwd) || exit 1 export STG_ROOT -stg_build_dir="$STG_ROOT"/build PYTHON="${PYTHON:-python}" -python_major_minor="$($PYTHON -c ' -import sys -print(".".join(map(str, sys.version_info[:2])))')" -stg_bin_dir="$stg_build_dir"/scripts-"$python_major_minor" +stg_build_dir="$STG_ROOT/build/lib" +stg_t_dir="$STG_ROOT/t" -if test ! -f "$stg_bin_dir"/stg +if test ! -f "$stg_build_dir/stgit/main.py" then - echo >&2 "error: $stg_bin_dir missing (has stg been built?)." + echo >&2 "error: $stg_build_dir/stgit/main.py missing (has stg been built?)." exit 1 fi PERL_PATH=${PERL:-perl} @@ -56,8 +53,8 @@ export PERL_PATH SHELL_PATH ################################################################ # It appears that people try to run tests without building... -"${STG_TEST_INSTALLED:-$stg_bin_dir}/stg" 2> /dev/null -if test $? != 1 +"${STG_TEST_INSTALLED:-$stg_build_dir/stgit/main.py}" 2> /dev/null +if test ! \( -f "${STG_TEST_INSTALLED}/stg" -o -f "${stg_build_dir}/stgit/main.py" \) then if test -n "$STG_TEST_INSTALLED" then @@ -1069,14 +1066,13 @@ if test -n "$STG_TEST_INSTALLED" then PATH=$STG_TEST_INSTALLED:$PATH else - PATH="$stg_bin_dir:$PATH" - PYTHONPATH="$STG_ROOT":"$PYTHONPATH" + PATH=$stg_t_dir:$PATH fi GIT_EXEC_PATH=$(git --exec-path) || error "Cannot run git" unset GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM=1 GIT_ATTR_NOSYSTEM=1 -export PATH GIT_EXEC_PATH PYTHONPATH GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM +export PATH GIT_EXEC_PATH GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM if test -z "$GIT_TEST_CMP" then