Menu
  • HOME
  • TAGS

Implementing Pull with Pygit2

python,libgit2,pygit2

First Solution (Not Recommended): You should not do this. It is possible to lose work this way. However, it works as a hacky solution. master_ref = repo.lookup_reference('refs/heads/master') master_ref.set_target(remote_master_id) # Terrible hack to fix set_target() screwing with the index repo.reset(master_ref.target, pygit2.GIT_RESET_HARD) Full source Second Solution: This one seems to be promising....

Getting full indexes of a patch using libgit2 / git2go

git,go,patch,libgit2,pygit2

So I've managed to get some outside help. If anyone runs into the same issue, it can be returned using: git_diff_options in libgit2 and setting id_abbrev to 40. https://libgit2.github.com/libgit2/#HEAD/type/git_diff_options or DiffOptions in git2go and setting IdAbbrev to 40. https://godoc.org/github.com/libgit2/git2go#DiffOptions...

Does Repository.walk traverse all commits

python,git,libgit2,pygit2

Found relevant material in this answer. Repository.walk does not care about dangling commits, however git_odb_foreach can be used, which in pygit2 terms simply translates to iterating the repository object (check the Repository_as_iter function)....

Extract commits related to code changes from commit tree

python,github,github-api,pygit2

If that is possible, how do we get the list of modified files? Ah, now you're asking the right questions! Git, of course, does not store a list of modified files in each commit. Rather, each commit represents the state of the entire repository at a certain point in...

How to print the contents of a pygit object in python

python,git,pygit2

Let's check the documentation for pygit2: $ pydoc pygit2.Diff | ---------------------------------- | Data descriptors defined here: | | patch | Patch diff string. Okay, so let's try that: >>> out=repo.diff(t0,t1) >>> print out <_pygit2.Diff object at 0x7fc46eeb0410> >>> print out.patch diff --git a/file1 b/file1 index 10952f3..66ed2b8 100644 --- a/file1 +++...

Unusual behavior of jinja2 template_filter decorator in flask application

python-2.7,flask,jinja2,pygit2

Just putting those filter definitions in a module doesn't run them, you need to actually import the module after creating the app. This will run the code and register the filters. # ... app = Flask(__name__) # ... from fresque import filters ...

How to set the credentials in pygit2.clone_repository?

github,libgit2,pygit2

Does using the exact same username and password work with git? If you have two-factor authentication activated, your normal password won't work. You have to create a new token and use that as your password. Also make sure that the error is due to the credentials. "security error" could just...