◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
4 changes: 1 addition & 3 deletions .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ jobs:
command -v git python
git version
python --version
python -c 'import sys; print(sys.platform)'
python -c 'import os; print(os.name)'
python -c 'import git; print(git.compat.is_win)' # NOTE: Deprecated. Use os.name directly.

- name: Test with pytest
run: |
Expand Down
26 changes: 20 additions & 6 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ permissions:

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- experimental: false

defaults:
run:
shell: /bin/bash --noprofile --norc -exo pipefail {0}

steps:
- uses: actions/checkout@v4
Expand All @@ -34,6 +35,12 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: ${{ matrix.experimental }}

- name: Prepare this repo for tests
run: |
./init-tests-after-clone.sh
Expand Down Expand Up @@ -61,9 +68,16 @@ jobs:
command -v git python
git version
python --version
python -c 'import sys; print(sys.platform)'
python -c 'import os; print(os.name)'
python -c 'import git; print(git.compat.is_win)' # NOTE: Deprecated. Use os.name directly.

- name: Check types with mypy
run: |
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pytest-cov
pytest-instafail
pytest-mock
pytest-sugar
30 changes: 13 additions & 17 deletions test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,17 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

import ddt
import shutil
import tempfile
from git import (
Repo,
GitCommandError,
Diff,
DiffIndex,
NULL_TREE,
Submodule,
)
from git.cmd import Git
from test.lib import (
TestBase,
StringProcessAdapter,
fixture,
)
from test.lib import with_rw_directory

import os.path as osp


def to_raw(input):
Expand Up @@ -318,6 +309,11 @@ def test_diff_with_spaces(self):
self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path))
self.assertEqual(diff_index[0].b_path, "file with spaces", repr(diff_index[0].b_path))

def test_diff_submodule(self):
"""Test that diff is able to correctly diff commits that cover submodule changes"""
# Init a temp git repo that will be referenced as a submodule.
Expand Down
11 changes: 9 additions & 2 deletions test/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

import pytest

from test.lib import TestBase
from test.lib.helper import with_rw_directory

import os.path


class Tutorials(TestBase):
def tearDown(self):
Expand Down Expand Up @@ -207,6 +206,14 @@ def update(self, op_code, cur_count, max_count=None, message=""):
assert sm.module_exists() # The submodule's working tree was checked out by update.
# ![14-test_init_repo_object]

@with_rw_directory
def test_references_and_objects(self, rw_dir):
# [1-test_references_and_objects]
Expand Down
17 changes: 14 additions & 3 deletions test/test_fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

from io import BytesIO
from stat import S_IFDIR, S_IFREG, S_IFLNK, S_IXUSR
from os import stat
import os.path as osp

from git import Git
from git.index import IndexFile
from git.index.fun import (
aggressive_tree_merge,
Expand Down Expand Up @@ -34,6 +37,14 @@ def _assert_index_entries(self, entries, trees):
assert (entry.path, entry.stage) in index.entries
# END assert entry matches fully

def test_aggressive_tree_merge(self):
# Head tree with additions, removals and modification compared to its predecessor.
odb = self.rorepo.odb
Expand Down Expand Up @@ -291,12 +302,12 @@ def test_linked_worktree_traversal(self, rw_dir):
rw_master.git.worktree("add", worktree_path, branch.name)

dotgit = osp.join(worktree_path, ".git")
statbuf = stat(dotgit)
self.assertTrue(statbuf.st_mode & S_IFREG)

gitdir = find_worktree_git_dir(dotgit)
self.assertIsNotNone(gitdir)
statbuf = stat(gitdir)
self.assertTrue(statbuf.st_mode & S_IFDIR)

def test_tree_entries_from_data_with_failing_name_decode_py3(self):
Expand Down
Loading
Toggle all file notes Toggle all file annotations