ZyX_I avatar ZyX_I committed bd1be2a

@aurum/drivers/git: Added rf-getrepoprop()

Comments (0)

Files changed (2)

plugin/aurum/drivers/git.vim

             \    'rlf': 'Failed to list commits in repository %s: %s',
             \    'lbf': 'Failed to create/remove %s %s for revision %s '.
             \           'in the repository %s: %s',
+            \'branchf': 'Failed to get list of branches '.
+            \           'from the repository %s: %s',
+            \   'tagf': 'Failed to get list of tags from the repository %s: %s',
             \ 'cbnimp': 'Git driver is not able to close branch',
             \   'nloc': 'Git driver does not suppport local tags or branches',
             \   'chbf': 'Failed to create branch %s in the repository %s: %s',
+            \  'nocfg': 'Failed to get property %s of repository %s',
         \}
 let s:git={}
 "▶1 s:hypsites
         return printf(s:diffre, 'a', 'b')
     endif
 endfunction
-"▶1 diffname :: _, line, diffre, _ → rpath
+"▶1 git.diffname :: _, line, diffre, _ → rpath
 function s:git.diffname(repo, line, diffre, opts)
     return s:F.refile(get(matchlist(a:line, a:diffre), 1, 0))[2:]
 endfunction
     return s:F.gitm(a:repo, a:type, args, kwargs, 0,
                 \   'lbf', a:type, a:label, a:rev)
 endfunction
+"▶1 git.getrepoprop :: repo, propname → a
+function s:git.getrepoprop(repo, prop)
+    if a:prop is# 'url'
+        let r=get(s:F.git(a:repo, 'config', ['remote.origin.pushurl'], {}, 0),
+                    \0, 0)
+        if v:shell_error || 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'
+        return map(s:F.git(a:repo, 'branch', [], {'l': 1}, 0,
+                    \      'branchf')[:-2], 'v:val[2:]')
+    elseif a:prop is# 'tagslist'
+        return s:F.git(a:repo, 'branch', [], {'l': 1}, 0, 'tagf')[:-2]
+    elseif a:prop is# 'bookmarkslist'
+        return []
+    endif
+    call s:_f.throw('nocfg', a:prop, a:repo.path)
+endfunction
 "▶1 git.repo :: path → repo
 function s:git.repo(path)
     let repo={'path': a:path, 'changesets': {}, 'cslist': [],

plugin/aurum/drivers/mercurial.vim

             \ 'destex': 'Cannot copy %s to %s: destination already exists',
             \ 'nhgiwr': 'File %s is either a directory or not writeable',
             \'reponwr': 'Unable to write to repository root (%s)',
-            \  'nocfg': 'Failed to get property %s of repository %s ',
+            \  'nocfg': 'Failed to get property %s of repository %s',
             \'nlocbms': 'Bookmarks can’t be local',
         \}
 if !s:usepythondriver
 endfunction
 else "▶2
 function s:hg.getrepoprop(repo, prop)
-    if a:prop is# 'tagslist' || a:prop is# 'brancheslist' || a:prop is# 'bookmarkslist'
+    if a:prop is# 'tagslist' || a:prop is# 'brancheslist' ||
+                \               a:prop is# 'bookmarkslist'
         return map(copy(s:F.getkeylist(a:repo, a:prop[:-5])), 'v:val[0]')
     elseif a:prop is# 'url'
         let lines=s:F.hg(a:repo, 'showconfig paths', 0, 'sc')[:-2]
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.