Skip to content

Commit 3a84459

Browse files
committed
add travis
2 parents df39446 + 636f77b commit 3a84459

File tree

13 files changed

+144
-19
lines changed

13 files changed

+144
-19
lines changed

.travis.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# UNUSED, only for reference. If adjustments are needed, please see github actions
2+
language: python
3+
python:
4+
<<<<<<< HEAD
5+
- "3.4"
6+
=======
7+
>>>>>>> b0f79c58ad919e90261d1e332df79a4ad0bc40de
8+
- "3.6"
9+
- "3.7"
10+
- "3.8"
11+
- "nightly"
12+
# - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details)
13+
matrix:
14+
allow_failures:
15+
- python: "nightly"
16+
git:
17+
# a higher depth is needed for most of the tests - must be high enough to not actually be shallow
18+
# as we clone our own repository in the process
19+
depth: 99999
20+
install:
21+
- python --version; git --version
22+
- git submodule update --init --recursive
23+
- git fetch --tags
24+
- pip install -r test-requirements.txt
25+
- pip install -r doc/requirements.txt
26+
- pip install codecov
27+
28+
# generate some reflog as git-python tests need it (in master)
29+
- ./init-tests-after-clone.sh
30+
31+
# as commits are performed with the default user, it needs to be set for travis too
32+
- git config --global user.email "travis@ci.com"
33+
- git config --global user.name "Travis Runner"
34+
# If we rewrite the user's config by accident, we will mess it up
35+
# and cause subsequent tests to fail
36+
- cat git/test/fixtures/.gitconfig >> ~/.gitconfig
37+
script:
38+
# Make sure we limit open handles to see if we are leaking them
39+
- ulimit -n 128
40+
- ulimit -n
41+
- coverage run --omit="test/*" -m unittest --buffer
42+
- coverage report
43+
- if [ "$TRAVIS_PYTHON_VERSION" == '3.6' ]; then cd doc && make html; fi
44+
- if [ "$TRAVIS_PYTHON_VERSION" == '3.6' ]; then flake8 --ignore=W293,E265,E266,W503,W504,E731; fi
45+
after_success:
46+
- codecov

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ Contributors are:
4343
-Liam Beguin <liambeguin _at_ gmail.com>
4444
-Ram Rachum <ram _at_ rachum.com>
4545
-Alba Mendez <me _at_ alba.sh>
46+
-Robert Westman <robert _at_ byteflux.io>
4647
Portions derived from other open source works and are clearly marked.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.17
1+
3.1.18

doc/source/changes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Changelog
33
=========
44

5+
3.1.18
6+
======
7+
8+
* drop support for python 3.5 to reduce maintenance burden on typing. Lower patch levels of python 3.5 would break, too.
9+
10+
See the following for details:
11+
https://github.com/gitpython-developers/gitpython/milestone/50?closed=1
12+
513
3.1.17
614
======
715

git/cmd.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
import subprocess
1818
import sys
1919
import threading
20-
from collections import OrderedDict
2120
from textwrap import dedent
22-
import warnings
2321

2422
from git.compat import (
2523
defenc,
@@ -1004,13 +1002,6 @@ def transform_kwarg(self, name: str, value: Any, split_single_char_options: bool
10041002

10051003
def transform_kwargs(self, split_single_char_options: bool = True, **kwargs: Any) -> List[str]:
10061004
"""Transforms Python style kwargs into git command line options."""
1007-
# Python 3.6 preserves the order of kwargs and thus has a stable
1008-
# order. For older versions sort the kwargs by the key to get a stable
1009-
# order.
1010-
if sys.version_info[:2] < (3, 6):
1011-
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
1012-
warnings.warn("Python 3.5 support is deprecated and will be removed 2021-09-05.\n" +
1013-
"It does not preserve the order for key-word arguments and enforce lexical sorting instead.")
10141005
args = []
10151006
for k, v in kwargs.items():
10161007
if isinstance(v, (list, tuple)):

git/index/fun.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
S_ISDIR,
1212
S_IFMT,
1313
S_IFREG,
14+
S_IXUSR,
1415
)
1516
import subprocess
1617

@@ -115,7 +116,7 @@ def stat_mode_to_index_mode(mode: int) -> int:
115116
return S_IFLNK
116117
if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK: # submodules
117118
return S_IFGITLINK
118-
return S_IFREG | 0o644 | (mode & 0o111) # blobs with or without executable bit
119+
return S_IFREG | (mode & S_IXUSR and 0o755 or 0o644) # blobs with or without executable bit
119120

120121

121122
def write_cache(entries: Sequence[Union[BaseIndexEntry, 'IndexEntry']], stream: IO[bytes],

git/refs/tag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class TagReference(Reference):
1818
print(tagref.tag.message)"""
1919

2020
__slots__ = ()
21-
_common_path_default = "refs/tags"
21+
_common_default = "tags"
22+
_common_path_default = Reference._common_path_default + "/" + _common_default
2223

2324
@property
2425
def commit(self):

git/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def stale_refs(self) -> IterableList:
612612
# * [would prune] origin/new_branch
613613
token = " * [would prune] "
614614
if not line.startswith(token):
615-
raise ValueError("Could not parse git-remote prune result: %r" % line)
615+
continue
616616
ref_name = line.replace(token, "")
617617
# sometimes, paths start with a full ref name, like refs/tags/foo, see #260
618618
if ref_name.startswith(Reference._common_path_default + '/'):

git/repo/base.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
76
import logging
87
import os
98
import re
109
import warnings
1110

11+
from gitdb.exc import BadObject
12+
1213
from git.cmd import (
1314
Git,
1415
handle_process_output
@@ -402,7 +403,17 @@ def tags(self) -> 'IterableList':
402403
def tag(self, path: PathLike) -> TagReference:
403404
""":return: TagReference Object, reference pointing to a Commit or Tag
404405
:param path: path to the tag reference, i.e. 0.1.5 or tags/0.1.5 """
405-
return TagReference(self, path)
406+
full_path = self._to_full_tag_path(path)
407+
return TagReference(self, full_path)
408+
409+
@staticmethod
410+
def _to_full_tag_path(path):
411+
if path.startswith(TagReference._common_path_default + '/'):
412+
return path
413+
if path.startswith(TagReference._common_default + '/'):
414+
return Reference._common_path_default + '/' + path
415+
else:
416+
return TagReference._common_path_default + '/' + path
406417

407418
def create_head(self, path: PathLike, commit: str = 'HEAD',
408419
force: bool = False, logmsg: Optional[str] = None
@@ -608,6 +619,23 @@ def is_ancestor(self, ancestor_rev: 'Commit', rev: 'Commit') -> bool:
608619
raise
609620
return True
610621

622+
def is_valid_object(self, sha: str, object_type: str = None) -> bool:
623+
try:
624+
complete_sha = self.odb.partial_to_complete_sha_hex(sha)
625+
object_info = self.odb.info(complete_sha)
626+
if object_type:
627+
if object_info.type == object_type.encode():
628+
return True
629+
else:
630+
log.debug("Commit hash points to an object of type '%s'. Requested were objects of type '%s'",
631+
object_info.type.decode(), object_type)
632+
return False
633+
else:
634+
return True
635+
except BadObject:
636+
log.debug("Commit hash is invalid.")
637+
return False
638+
611639
def _get_daemon_export(self) -> bool:
612640
if self.git_dir:
613641
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)

git/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def _parse_progress_line(self, line: AnyStr) -> None:
470470
line_str = line
471471
self._cur_line = line_str
472472

473-
if self.error_lines or self._cur_line.startswith(('error:', 'fatal:')):
473+
if self._cur_line.startswith(('error:', 'fatal:')):
474474
self.error_lines.append(self._cur_line)
475475
return
476476

0 commit comments

Comments
 (0)