Skip to content

retrieving commits from branch names with UTF characters #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
valeriocos opened this issue Sep 20, 2016 · 1 comment
Closed

retrieving commits from branch names with UTF characters #515

valeriocos opened this issue Sep 20, 2016 · 1 comment

Comments

@valeriocos
Copy link

I'm using GitPython to retrieve all commits per branch from the rails repository (https://github.com/rails/rails). I'm encountering some problems when trying to get commits from the following branch: https://github.com/rails/rails/tree/%E0%B2%A0_%E0%B2%A0

Below you can find the code to replicate this issue:

from git import *

GIT_REPO_PATH = "PATH_TO_RAILS_REPO"


def get_commits(repo, ref_name):
    commits = []
    for commit in repo.iter_commits(rev=ref_name):
        commits.append(commit)
    return commits


def main():
    repo = Repo(GIT_REPO_PATH, odbt=GitCmdObjectDB)
    for ref in repo.references:
        print ref.name
        print str(len(get_commits(repo, ref.name)))
        print "---"

if __name__ == "__main__":
    main()
@Byron
Copy link
Member

Byron commented Sep 25, 2016

Thanks for providing the script to reproduce it ! Unfortunately (or fortunately), on the latest version of GitPython, this is no issue anymore. Here is the respective part of the scripts output:

[...]
---
origin/unlock-minitest
59577
---
origin/v5.0.0.beta2
56231
---
origin/ಠ_ಠ
58198
---
list
23682
---
[...]

Please note that I am testing this on MacOS with LC_CTYPE=UTF-8, which can have a major impact on how python tries to encode its output.

Please feel free to comment on the issue, which I am closing now just to keep it easy for me. If you find something I can reproduce, I will happily reopen it though.

And this is my version of the reproduction script. It's just setting the path-to-repo accordingly.
from git import *

GIT_REPO_PATH = "rails"


def get_commits(repo, ref_name):
    commits = []
    for commit in repo.iter_commits(rev=ref_name):
        commits.append(commit)
    return commits


def main():
    repo = Repo(GIT_REPO_PATH, odbt=GitCmdObjectDB)
    for ref in repo.references:
        print ref.name
        print str(len(get_commits(repo, ref.name)))
        print "---"

if __name__ == "__main__":
    main()

@Byron Byron closed this as completed Sep 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants