◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Prepare this repo for tests
run: |
TRAVIS=yes ./init-tests-after-clone.sh

- name: Set git user identity and command aliases for the tests
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ jobs:
python-version: "3.x"

- uses: pre-commit/action@v3.0.0
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Prepare this repo for tests
run: |
TRAVIS=yes ./init-tests-after-clone.sh

- name: Set git user identity and command aliases for the tests
run: |
Expand Down
52 changes: 37 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
repos:
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.9.16
- flake8-comprehensions==3.14.0
- flake8-typing-imports==1.14.0
exclude: ^doc|^git/ext/

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,20 @@ To clone the [the GitHub repository](https://github.com/gitpython-developers/Git
```bash
git clone https://github.com/gitpython-developers/GitPython
cd GitPython
git fetch --tags
./init-tests-after-clone.sh
```

If you are cloning [your own fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks), then replace the above `git clone` command with one that gives the URL of your fork. Or use this [`gh`](https://cli.github.com/) command (assuming you have `gh` and your fork is called `GitPython`):

```bash
gh repo clone GitPython
```

Having cloned the repo, create and activate your [virtual environment](https://docs.python.org/3/tutorial/venv.html). Then make an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs):

```bash
pip install -e ".[test]"
Expand Down Expand Up @@ -114,9 +117,9 @@ See [Issue #525](https://github.com/gitpython-developers/GitPython/issues/525).

### RUNNING TESTS

_Important_: Right after cloning this repository, please be sure to have
executed `git fetch --tags` followed by the `./init-tests-after-clone.sh`
script in the repository root. Otherwise you will encounter test failures.

On _Windows_, make sure you have `git-daemon` in your PATH. For MINGW-git, the `git-daemon.exe`
exists in `Git\mingw64\libexec\git-core\`.
Expand All @@ -143,30 +146,41 @@ To test, run:
pytest
```

To lint, run:

```bash
pre-commit run --all-files
```

To typecheck, run:

```bash
mypy -p git
```

For automatic code formatting, run:

```bash
black .
```

Configuration for flake8 is in the `./.flake8` file.

Configurations for `mypy`, `pytest`, `coverage.py`, and `black` are in `./pyproject.toml`.

The same linting and testing will also be performed against different supported python versions
upon submitting a pull request (or on each push if you have a fork with a "main" branch and actions enabled).

### Contributions

Expand Down
15 changes: 8 additions & 7 deletions build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
set -eEu

function release_with() {
$1 -m build --sdist --wheel
}

if test -n "${VIRTUAL_ENV:-}"; then
deps=(build twine) # Install twine along with build, as we need it later.
echo "Virtual environment detected. Adding packages: ${deps[*]}"
pip install --quiet --upgrade "${deps[@]}"
echo 'Starting the build.'
release_with python
else
function suggest_venv() {
venv_cmd='python -m venv env && source env/bin/activate'
printf "HELP: To avoid this error, use a virtual-env with '%s' instead.\n" "$venv_cmd"
}
trap suggest_venv ERR # This keeps the original exit (error) code.
echo 'Starting the build.'
release_with python3 # Outside a venv, use python3.
fi
26 changes: 18 additions & 8 deletions check-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,39 @@ trap 'echo "$0: Check failed. Stopping." >&2' ERR
readonly version_path='VERSION'
readonly changes_path='doc/source/changes.rst'

echo 'Checking current directory.'
test "$(cd -- "$(dirname -- "$0")" && pwd)" = "$(pwd)" # Ugly, but portable.

echo "Checking that $version_path and $changes_path exist and have no uncommitted changes."
test -f "$version_path"
test -f "$changes_path"
git status -s -- "$version_path" "$changes_path"
test -z "$(git status -s -- "$version_path" "$changes_path")"

# This section can be commented out, if absolutely necessary.
echo 'Checking that ALL changes are committed.'
git status -s --ignore-submodules
test -z "$(git status -s --ignore-submodules)"

version_version="$(cat "$version_path")"
changes_version="$(awk '/^[0-9]/ {print $0; exit}' "$changes_path")"
config_opts="$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)"
latest_tag="$(git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1)"
head_sha="$(git rev-parse HEAD)"
latest_tag_sha="$(git rev-parse "${latest_tag}^{commit}")"

# Display a table of all the current version, tag, and HEAD commit information.
echo $'\nThe VERSION must be the same in all locations, and so must the HEAD and tag SHA'
printf '%-14s = %s\n' 'VERSION file' "$version_version" \
'changes.rst' "$changes_version" \
'Latest tag' "$latest_tag" \
Expand Down
43 changes: 22 additions & 21 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#

# You can set these variables from the command line.
SPHINXOPTS = -W
SPHINXBUILD = sphinx-build
PAPER =

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html web pickle htmlhelp latex changes linkcheck

@@ -24,52 +25,52 @@ help:
@echo " linkcheck to check all external links for integrity"

clean:
-rm -rf build/*

html:
mkdir -p build/html build/doctrees
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
@echo
@echo "Build finished. The HTML pages are in build/html."

pickle:
mkdir -p build/pickle build/doctrees
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
@echo
@echo "Build finished; now you can process the pickle files."

web: pickle

json:
mkdir -p build/json build/doctrees
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
mkdir -p build/htmlhelp build/doctrees
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in build/htmlhelp."

latex:
mkdir -p build/latex build/doctrees
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
@echo
@echo "Build finished; the LaTeX files are in build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."

changes:
mkdir -p build/changes build/doctrees
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
@echo
@echo "The overview file is in build/changes."

linkcheck:
mkdir -p build/linkcheck build/doctrees
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in build/linkcheck/output.txt."
Loading
Toggle all file notes Toggle all file annotations