◐ Shell
reader mode source ↗
Skip to content
Merged
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
44 changes: 27 additions & 17 deletions .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
env:
CHERE_INVOKING: 1
SHELLOPTS: igncr
TMP: "/tmp"
TEMP: "/tmp"
defaults:
run:
shell: bash.exe --noprofile --norc -exo pipefail -o igncr "{0}"

steps:
- name: Force LF line endings
run: git config --global core.autocrlf input

- uses: actions/checkout@v4
with:
Expand All @@ -29,36 +33,42 @@ jobs:
with:
packages: python39 python39-pip python39-virtualenv git

- name: Show python and git versions
run: |
/usr/bin/python --version
/usr/bin/git version

- name: Tell git to trust this repo
run: |
/usr/bin/git config --global --add safe.directory "$(pwd)"

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

- name: Further prepare git configuration for tests
run: |
/usr/bin/git config --global user.email "travis@ci.com"
/usr/bin/git config --global user.name "Travis Runner"
# If we rewrite the user's config by accident, we will mess it up
# and cause subsequent tests to fail
cat test/fixtures/.gitconfig >> ~/.gitconfig

- name: Update PyPA packages
run: |
/usr/bin/python -m pip install --upgrade pip setuptools wheel

- name: Install project and test dependencies
run: |
/usr/bin/python -m pip install ".[test]"

- name: Test with pytest
run: |
set +x
/usr/bin/python -m pytest
12 changes: 7 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.0
30 changes: 16 additions & 14 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ permissions:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -20,6 +20,7 @@ jobs:
- experimental: false
- python-version: "3.12"
experimental: true
defaults:
run:
shell: /bin/bash --noprofile --norc -exo pipefail {0}
Expand All @@ -36,16 +37,11 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: ${{ matrix.experimental }}

- name: Show python and git versions
run: |
python --version
git version

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

- name: Prepare git configuration for tests
run: |
git config --global user.email "travis@ci.com"
git config --global user.name "Travis Runner"
Expand All @@ -55,17 +51,23 @@ jobs:

- name: Update PyPA packages
run: |
python -m pip install --upgrade pip
if pip freeze --all | grep --quiet '^setuptools=='; then
# Python prior to 3.12 ships setuptools. Upgrade it if present.
python -m pip install --upgrade setuptools
fi
python -m pip install --upgrade wheel

- name: Install project and test dependencies
run: |
pip install ".[test]"

- name: Check types with mypy
run: |
mypy -p git
Expand All @@ -75,7 +77,7 @@ jobs:

- name: Test with pytest
run: |
pytest
continue-on-error: false

- name: Documentation
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
python_files = 'test_*.py'
testpaths = 'test' # space separated list of paths from root e.g test tests doc/testing
addopts = '--cov=git --cov-report=term --maxfail=10 --force-sugar --disable-warnings'
filterwarnings = 'ignore::DeprecationWarning'
# --cov coverage
# --cov-report term # send report to terminal term-missing -> terminal with line numbers html xml
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mypy
pre-commit
pytest
pytest-cov
pytest-sugar
4 changes: 2 additions & 2 deletions test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import sys
import tempfile
from unittest import SkipTest, skipIf

from git import Repo
from git.objects import Blob, Tree, Commit, TagObject
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_add_unicode(self, rw_repo):
try:
file_path.encode(sys.getfilesystemencoding())
except UnicodeEncodeError as e:
raise SkipTest("Environment doesn't support unicode filenames") from e

with open(file_path, "wb") as fp:
fp.write(b"something")
Expand Down
3 changes: 1 addition & 2 deletions test/test_fun.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
from stat import S_IFDIR, S_IFREG, S_IFLNK, S_IXUSR
from os import stat
import os.path as osp
from unittest import SkipTest

from git import Git
from git.index import IndexFile
Expand Down @@ -279,7 +278,7 @@ def test_linked_worktree_traversal(self, rw_dir):
"""Check that we can identify a linked worktree based on a .git file"""
git = Git(rw_dir)
if git.version_info[:3] < (2, 5, 1):
raise SkipTest("worktree feature unsupported")

rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
branch = rw_master.create_head("aaaaaaaa")
Expand Down
42 changes: 23 additions & 19 deletions test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@

from io import BytesIO
import os
from stat import S_ISLNK, ST_MODE
import tempfile
from unittest import skipIf
import shutil

from git import (
IndexFile,
Expand All @@ -28,21 +31,26 @@
from git.index.fun import hook_path
from git.index.typ import BaseIndexEntry, IndexEntry
from git.objects import Blob
from test.lib import TestBase, fixture_path, fixture, with_rw_repo
from test.lib import with_rw_directory
from git.util import Actor, rmtree
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, hex_to_bin
from gitdb.base import IStream

import os.path as osp
from git.cmd import Git

from pathlib import Path

HOOKS_SHEBANG = "#!/usr/bin/env sh\n"

is_win_without_bash = is_win and not shutil.which("bash.exe")


def _make_hook(git_dir, name, content, make_exec=True):
"""A helper to create a hook"""
Expand Down Expand Up @@ -422,14 +430,6 @@ def _count_existing(self, repo, files):

# END num existing helper

@skipIf(
HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
"""FIXME: File "C:\\projects\\gitpython\\git\\test\\test_index.py", line 642, in test_index_mutation
self.assertEqual(fd.read(), link_target)
AssertionError: '!<symlink>\xff\xfe/\x00e\x00t\x00c\x00/\x00t\x00h\x00a\x00t\x00\x00\x00'
!= '/etc/that'
""",
)
@with_rw_repo("0.1.6")
def test_index_mutation(self, rw_repo):
index = rw_repo.index
Expand Down Expand Up @@ -910,7 +910,11 @@ def test_pre_commit_hook_fail(self, rw_repo):
else:
raise AssertionError("Should have caught a HookExecutionError")

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS, "TODO: fix hooks execution on Windows: #703")
@with_rw_repo("HEAD", bare=True)
def test_commit_msg_hook_success(self, rw_repo):
commit_message = "commit default head by Frèderic Çaufl€"
22 changes: 5 additions & 17 deletions test/test_repo.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import pickle
import sys
import tempfile
from unittest import mock, skipIf, SkipTest, skip

import pytest

Expand Down Expand Up @@ -41,10 +41,8 @@
UnsafeProtocolError,
)
from git.repo.fun import touch
from test.lib import TestBase, with_rw_repo, fixture
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, cygpath
from test.lib import with_rw_directory
from git.util import join_path_native, rmtree, rmfile, bin_to_hex

import os.path as osp

Expand Down Expand Up @@ -764,16 +762,6 @@ def test_blame_accepts_rev_opts(self, git):
self.rorepo.blame("HEAD", "README.md", rev_opts=["-M", "-C", "-C"])
git.assert_called_once_with(*expected_args, **boilerplate_kwargs)

@skipIf(
HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
"""FIXME: File "C:\\projects\\gitpython\\git\\cmd.py", line 671, in execute
raise GitCommandError(command, status, stderr_value, stdout_value)
GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git add 1__��ava verb��ten 1_test _myfile 1_test_other_file
1_��ava-----verb��ten
stderr: 'fatal: pathspec '"1__çava verböten"' did not match any files'
""",
)
@with_rw_repo("HEAD", bare=False)
def test_untracked_files(self, rwrepo):
for run, repo_add in enumerate((rwrepo.index.add, rwrepo.git.add)):
Expand Down Expand Up @@ -1245,7 +1233,7 @@ def test_merge_base(self):
def test_is_ancestor(self):
git = self.rorepo.git
if git.version_info[:3] < (1, 8, 0):
raise SkipTest("git merge-base --is-ancestor feature unsupported")

repo = self.rorepo
c1 = "f6aa8d1"
Expand Up @@ -1293,7 +1281,7 @@ def test_git_work_tree_dotgit(self, rw_dir):
based on it."""
git = Git(rw_dir)
if git.version_info[:3] < (2, 5, 1):
raise SkipTest("worktree feature unsupported")

rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
branch = rw_master.create_head("aaaaaaaa")
Expand Down
Loading
Toggle all file notes Toggle all file annotations