mirror of
https://github.com/powerline/powerline.git
synced 2025-07-30 01:05:42 +02:00
Recreate git.Repository() on each call
It appears that pygit2 has similar to mercurial’s issue with statuses (they are not updated) and needs to be regenerated on each call as well. Implies to index statuses only though, that is why I used to think pygit2 does not have this problem.
This commit is contained in:
parent
3addf44a6d
commit
5b43960e0e
@ -2,11 +2,13 @@ try:
|
|||||||
import pygit2 as git
|
import pygit2 as git
|
||||||
|
|
||||||
class Repository(object):
|
class Repository(object):
|
||||||
__slots__ = ('repo', 'directory')
|
__slots__ = ('directory')
|
||||||
|
|
||||||
def __init__(self, directory):
|
def __init__(self, directory):
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
self.repo = git.Repository(directory)
|
|
||||||
|
def _repo(self):
|
||||||
|
return git.Repository(self.directory)
|
||||||
|
|
||||||
def status(self, path=None):
|
def status(self, path=None):
|
||||||
'''Return status of repository or file.
|
'''Return status of repository or file.
|
||||||
@ -23,7 +25,7 @@ try:
|
|||||||
(except for merge statuses as they are not supported by libgit2).
|
(except for merge statuses as they are not supported by libgit2).
|
||||||
'''
|
'''
|
||||||
if path:
|
if path:
|
||||||
status = self.repo.status_file(path)
|
status = self._repo().status_file(path)
|
||||||
|
|
||||||
if status == git.GIT_STATUS_CURRENT:
|
if status == git.GIT_STATUS_CURRENT:
|
||||||
return None
|
return None
|
||||||
@ -54,7 +56,7 @@ try:
|
|||||||
wt_column = ' '
|
wt_column = ' '
|
||||||
index_column = ' '
|
index_column = ' '
|
||||||
untracked_column = ' '
|
untracked_column = ' '
|
||||||
for status in self.repo.status():
|
for status in self._repo().status():
|
||||||
if status & (git.GIT_STATUS_WT_DELETED
|
if status & (git.GIT_STATUS_WT_DELETED
|
||||||
| git.GIT_STATUS_WT_MODIFIED):
|
| git.GIT_STATUS_WT_MODIFIED):
|
||||||
wt_column = 'D'
|
wt_column = 'D'
|
||||||
@ -68,7 +70,7 @@ try:
|
|||||||
|
|
||||||
def branch(self):
|
def branch(self):
|
||||||
try:
|
try:
|
||||||
ref = self.repo.lookup_reference('HEAD')
|
ref = self._repo().lookup_reference('HEAD')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user