summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-06-17 17:38:42 +0100
committerYobmod <yobmod@gmail.com>2021-06-17 17:38:42 +0100
commit3a84459c6a5a1d8a81e4a51189091ef135e1776e (patch)
treee1207dbe034f82deacbb76369716779608e7056d /git
parentdf39446bb7b90ab9436fa3a76f6d4182c2a47da2 (diff)
parent636f77bf8d58a482df0bde8c0a6a8828950a0788 (diff)
downloadgitpython-3a84459c6a5a1d8a81e4a51189091ef135e1776e.tar.gz
add travis
Diffstat (limited to 'git')
-rw-r--r--git/cmd.py9
-rw-r--r--git/index/fun.py3
-rw-r--r--git/refs/tag.py3
-rw-r--r--git/remote.py2
-rw-r--r--git/repo/base.py32
-rw-r--r--git/util.py2
6 files changed, 36 insertions, 15 deletions
diff --git a/git/cmd.py b/git/cmd.py
index d15b97ca..e078e4a1 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -17,9 +17,7 @@ from subprocess import (
import subprocess
import sys
import threading
-from collections import OrderedDict
from textwrap import dedent
-import warnings
from git.compat import (
defenc,
@@ -1004,13 +1002,6 @@ class Git(LazyMixin):
def transform_kwargs(self, split_single_char_options: bool = True, **kwargs: Any) -> List[str]:
"""Transforms Python style kwargs into git command line options."""
- # Python 3.6 preserves the order of kwargs and thus has a stable
- # order. For older versions sort the kwargs by the key to get a stable
- # order.
- if sys.version_info[:2] < (3, 6):
- kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0]))
- warnings.warn("Python 3.5 support is deprecated and will be removed 2021-09-05.\n" +
- "It does not preserve the order for key-word arguments and enforce lexical sorting instead.")
args = []
for k, v in kwargs.items():
if isinstance(v, (list, tuple)):
diff --git a/git/index/fun.py b/git/index/fun.py
index 96d9b475..3fded347 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -11,6 +11,7 @@ from stat import (
S_ISDIR,
S_IFMT,
S_IFREG,
+ S_IXUSR,
)
import subprocess
@@ -115,7 +116,7 @@ def stat_mode_to_index_mode(mode: int) -> int:
return S_IFLNK
if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK: # submodules
return S_IFGITLINK
- return S_IFREG | 0o644 | (mode & 0o111) # blobs with or without executable bit
+ return S_IFREG | (mode & S_IXUSR and 0o755 or 0o644) # blobs with or without executable bit
def write_cache(entries: Sequence[Union[BaseIndexEntry, 'IndexEntry']], stream: IO[bytes],
diff --git a/git/refs/tag.py b/git/refs/tag.py
index 8f88c522..4d84239e 100644
--- a/git/refs/tag.py
+++ b/git/refs/tag.py
@@ -18,7 +18,8 @@ class TagReference(Reference):
print(tagref.tag.message)"""
__slots__ = ()
- _common_path_default = "refs/tags"
+ _common_default = "tags"
+ _common_path_default = Reference._common_path_default + "/" + _common_default
@property
def commit(self):
diff --git a/git/remote.py b/git/remote.py
index e17f7bb8..6ea4b2a1 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -612,7 +612,7 @@ class Remote(LazyMixin, Iterable):
# * [would prune] origin/new_branch
token = " * [would prune] "
if not line.startswith(token):
- raise ValueError("Could not parse git-remote prune result: %r" % line)
+ continue
ref_name = line.replace(token, "")
# sometimes, paths start with a full ref name, like refs/tags/foo, see #260
if ref_name.startswith(Reference._common_path_default + '/'):
diff --git a/git/repo/base.py b/git/repo/base.py
index 2d2e915c..5abd4961 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -3,12 +3,13 @@
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
import logging
import os
import re
import warnings
+from gitdb.exc import BadObject
+
from git.cmd import (
Git,
handle_process_output
@@ -402,7 +403,17 @@ class Repo(object):
def tag(self, path: PathLike) -> TagReference:
""":return: TagReference Object, reference pointing to a Commit or Tag
:param path: path to the tag reference, i.e. 0.1.5 or tags/0.1.5 """
- return TagReference(self, path)
+ full_path = self._to_full_tag_path(path)
+ return TagReference(self, full_path)
+
+ @staticmethod
+ def _to_full_tag_path(path):
+ if path.startswith(TagReference._common_path_default + '/'):
+ return path
+ if path.startswith(TagReference._common_default + '/'):
+ return Reference._common_path_default + '/' + path
+ else:
+ return TagReference._common_path_default + '/' + path
def create_head(self, path: PathLike, commit: str = 'HEAD',
force: bool = False, logmsg: Optional[str] = None
@@ -608,6 +619,23 @@ class Repo(object):
raise
return True
+ def is_valid_object(self, sha: str, object_type: str = None) -> bool:
+ try:
+ complete_sha = self.odb.partial_to_complete_sha_hex(sha)
+ object_info = self.odb.info(complete_sha)
+ if object_type:
+ if object_info.type == object_type.encode():
+ return True
+ else:
+ log.debug("Commit hash points to an object of type '%s'. Requested were objects of type '%s'",
+ object_info.type.decode(), object_type)
+ return False
+ else:
+ return True
+ except BadObject:
+ log.debug("Commit hash is invalid.")
+ return False
+
def _get_daemon_export(self) -> bool:
if self.git_dir:
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
diff --git a/git/util.py b/git/util.py
index 76aaee49..edbd5f1e 100644
--- a/git/util.py
+++ b/git/util.py
@@ -470,7 +470,7 @@ class RemoteProgress(object):
line_str = line
self._cur_line = line_str
- if self.error_lines or self._cur_line.startswith(('error:', 'fatal:')):
+ if self._cur_line.startswith(('error:', 'fatal:')):
self.error_lines.append(self._cur_line)
return