ZyX_I avatar ZyX_I committed 58604ae

@%aurum/drivers/git: Made rf-getrepoprop() also use pygit2

Comments (0)

Files changed (1)

autoload/aurum/drivers/git.vim

     endif
 endfunction
 "▶1 git.getrepoprop :: repo, propname → a
-function s:git.getrepoprop(repo, prop)
-    if a:prop is# 'branch'
-        let branches=s:F.git(a:repo, 'branch', [], {'l': 1}, 0,
-                    \        'branchf')[:-2]
-        return get(filter(branches, 'v:val[0] is# "*"'), 0, '')[2:]
-    elseif a:prop is# 'url'
-        let [l, exit_code]=s:F.git(a:repo, 'config',
-                    \              ['remote.origin.pushurl'], {}, 0, 0)
-        let r=get(l, 0, 0)
-        if exit_code || r is 0
-            let r=get(s:F.git(a:repo, 'config', ['remote.origin.url'], {}, 0),
-                        \0, 0)
+if s:usepythondriver "▶2
+    function s:git.getrepoprop(repo, prop)
+        let d={}
+        try
+            execute s:pya.'get_repo_prop(vim.eval("a:repo.path"), '.
+                        \               'vim.eval("a:prop"))'
+        endtry
+        return d[a:prop]
+    endfunction
+else "▶2
+    function s:git.getrepoprop(repo, prop)
+        if a:prop is# 'branch'
+            let branches=s:F.git(a:repo, 'branch', [], {'l': 1}, 0,
+                        \        'branchf')[:-2]
+            return get(filter(branches, 'v:val[0] is# "*"'), 0, '')[2:]
+        elseif a:prop is# 'url'
+            let [l, exit_code]=s:F.git(a:repo, 'config',
+                        \              ['remote.origin.pushurl'], {}, 0, 0)
+            let r=get(l, 0, 0)
+            if exit_code || r is 0
+                let r=get(s:F.git(a:repo, 'config', ['remote.origin.url'],{},0),
+                            \0, 0)
+            endif
+            if r isnot 0
+                return r
+            endif
+        elseif a:prop is# 'branchslist' || a:prop is# 'brancheslist'
+            " XXX stridx(v:val, " ")==-1 filters out “(no branch)” item
+            return filter(map(s:F.git(a:repo, 'branch', [], {'l': 1}, 0,
+                        \             'branchf')[:-2], 'v:val[2:]'),
+                        \     'stridx(v:val, " ")==-1')
+        elseif a:prop is# 'tagslist'
+            return s:F.git(a:repo, 'tag', [], {}, 0, 'tagf')[:-2]
+        elseif a:prop is# 'bookmarkslist'
+            return []
         endif
-        if r isnot 0
-            return r
-        endif
-    elseif a:prop is# 'branchslist' || a:prop is# 'brancheslist'
-        " XXX stridx(v:val, " ")==-1 filters out “(no branch)” item
-        return filter(map(s:F.git(a:repo, 'branch', [], {'l': 1}, 0,
-                    \             'branchf')[:-2], 'v:val[2:]'),
-                    \     'stridx(v:val, " ")==-1')
-    elseif a:prop is# 'tagslist'
-        return s:F.git(a:repo, 'tag', [], {}, 0, 'tagf')[:-2]
-    elseif a:prop is# 'bookmarkslist'
-        return []
-    endif
-    call s:_f.throw('nocfg', a:prop, a:repo.path)
-endfunction
+        call s:_f.throw('nocfg', a:prop, a:repo.path)
+    endfunction
+endif
 "▶1 pushpull :: cmd, repo, dryrun, force[, URL[, rev]] → + ?
 function s:F.pushpull(cmd, repo, dryrun, force, ...)
     let kwargs1={}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.