MCPcopy Create free account
hub / github.com/libgit2/pygit2 / blame

Method blame

pygit2/repository.py:702–768  ·  view source on GitHub ↗

Return a Blame object for a single file. Parameters: path Path to the file to blame. flags An enums.BlameFlag constant. min_match_characters The number of alphanum chars that must be detected as moving/copying

(
        self,
        path: str,
        flags: BlameFlag = BlameFlag.NORMAL,
        min_match_characters: int | None = None,
        newest_commit: Oid | str | None = None,
        oldest_commit: Oid | str | None = None,
        min_line: int | None = None,
        max_line: int | None = None,
    )

Source from the content-addressed store, hash-verified

700 # blame
701 #
702 def blame(
703 self,
704 path: str,
705 flags: BlameFlag = BlameFlag.NORMAL,
706 min_match_characters: int | None = None,
707 newest_commit: Oid | str | None = None,
708 oldest_commit: Oid | str | None = None,
709 min_line: int | None = None,
710 max_line: int | None = None,
711 ) -> Blame:
712 """
713 Return a Blame object for a single file.
714
715 Parameters:
716
717 path
718 Path to the file to blame.
719
720 flags
721 An enums.BlameFlag constant.
722
723 min_match_characters
724 The number of alphanum chars that must be detected as moving/copying
725 within a file for it to associate those lines with the parent commit.
726
727 newest_commit
728 The id of the newest commit to consider.
729
730 oldest_commit
731 The id of the oldest commit to consider.
732
733 min_line
734 The first line in the file to blame.
735
736 max_line
737 The last line in the file to blame.
738
739 Examples::
740
741 repo.blame('foo.c', flags=enums.BlameFlag.IGNORE_WHITESPACE)
742 """
743
744 options = ffi.new('git_blame_options *')
745
746 C.git_blame_options_init(options, C.GIT_BLAME_OPTIONS_VERSION)
747 if flags:
748 options.flags = int(flags)
749 if min_match_characters:
750 options.min_match_characters = min_match_characters
751 if newest_commit:
752 if not isinstance(newest_commit, Oid):
753 newest_commit = Oid(hex=newest_commit)
754 ffi.buffer(ffi.addressof(options, 'newest_commit'))[:] = newest_commit.raw
755 if oldest_commit:
756 if not isinstance(oldest_commit, Oid):
757 oldest_commit = Oid(hex=oldest_commit)
758 ffi.buffer(ffi.addressof(options, 'oldest_commit'))[:] = oldest_commit.raw
759 if min_line:

Callers 6

test_blame_indexFunction · 0.80
test_blame_flagsFunction · 0.80
test_blame_for_lineFunction · 0.80
test_blame_newestFunction · 0.80

Calls 3

to_bytesFunction · 0.85
check_errorFunction · 0.85
_from_cMethod · 0.45

Tested by 6

test_blame_indexFunction · 0.64
test_blame_flagsFunction · 0.64
test_blame_for_lineFunction · 0.64
test_blame_newestFunction · 0.64