libgit2 / libgit2/pygit2

Broken GIT_SORT_TIME ?

Đang mở
#747 17 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
1.7k
Fork
408
Merge trung bình
2 ngày 57 phút
Pull request đã merge (30 ngày)
7

Mô tả

This is a script to reproduce the behavior I'm seeing:

#!/usr/bin/env python

import tempfile
import time
import os

import pygit2

path = tempfile.mkdtemp(prefix='pygit2_test_')
repo = pygit2.init_repository(path)

author = pygit2.Signature('Alice Author', 'alice@authors.tld')
committer = pygit2.Signature('Cecil Committer', 'cecil@committers.tld')

# Commit #1

 # Create a file in that git repo
with open(os.path.join(path, 'sources'), 'w') as stream:
    stream.write('foo\n bar')
repo.index.add('sources')
repo.index.write()

parents = []
# Commits the files added
tree = repo.index.write_tree()
print(repo.create_commit(
    'refs/heads/master',  # the name of the reference to update
    author,
    committer,
    'Commit #1',
    # binary string representing the tree object ID
    tree,
    # list of binary strings representing parents of the new commit
    parents,
))
commit1 = repo.revparse_single('HEAD')
time.sleep(0.1)

# Commit #2

parents = [commit1.oid.hex]

subfolder = os.path.join('folder1', 'folder2')
os.makedirs(os.path.join(path, subfolder))
# Create a file in that git repo
with open(os.path.join(path, subfolder, 'file'), 'w') as stream:
    stream.write('foo\n bar\nbaz')
repo.index.add(os.path.join(subfolder, 'file'))
repo.index.write()

# Commits the files added
tree = repo.index.write_tree()
print(repo.create_commit(
    'refs/heads/master',  # the name of the reference to update
    author,
    committer,
    'Commit #2',
    # binary string representing the tree object ID
    tree,
    # list of binary strings representing parents of the new commit
    parents
))
commit2 = repo.revparse_single('HEAD')
time.sleep(0.1)


# Commit #3

parents = [commit2.oid.hex]

# Update the sources file
with open(os.path.join(path, 'sources'), 'w') as stream:
    stream.write('foo\n bar\nbaz!')
repo.index.add('sources')
repo.index.write()

# Commits the files added
tree = repo.index.write_tree()
print(repo.create_commit(
    'refs/heads/master',  # the name of the reference to update
    author,
    committer,
    'Commit #3',
    # binary string representing the tree object ID
    tree,
    # list of binary strings representing parents of the new commit
    parents
))
commit3 = repo.revparse_single('HEAD')


print('')
main_walker = repo.walk(commit3.oid.hex, pygit2.GIT_SORT_TIME)
commits_msgs = []
while 1:
    try:
        com = main_walker.next()
        print(com.message)
        print(com.oid.hex)
    except StopIteration:
        break

It gives me the following output:

7335ffcfdb2039a9631ef5c891ec6a12feaeb342
50ea7d4691ee78b60323ac1d4174a6609190fbaf
47e61d2eaa8c5d3d1562475a43aa99c0e7fb9b8a

Commit #3
47e61d2eaa8c5d3d1562475a43aa99c0e7fb9b8a
Commit #1
7335ffcfdb2039a9631ef5c891ec6a12feaeb342
Commit #2
50ea7d4691ee78b60323ac1d4174a6609190fbaf

The first three lines are the commit as they are committed.
The following lines are the commit message and hash as repo.walk(commit3, pygit2.GIT_SORT_TIME) is returning them.

Something looks broken to me :)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy script tái hiện và kiểm tra binding pygit2 cho repo.walk với GIT_SORT_TIME. So sánh thứ tự quan sát được với hành vi sắp xếp được tài liệu hóa và các bài kiểm tra walker hiện có; công việc được xem là hoàn tất khi thứ tự được sửa hoặc hành vi được tài liệu hóa rõ ràng bằng một bài kiểm tra hồi quy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
git, python
Lĩnh vực
devtools
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.