Skip to content
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

Do not rely on English return string of git status -uno #12

Closed
kiryph opened this issue Nov 24, 2018 · 1 comment
Closed

Do not rely on English return string of git status -uno #12

kiryph opened this issue Nov 24, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@kiryph
Copy link

kiryph commented Nov 24, 2018

$ git status -uno returns if the locale language is e.g. German

:!git status -uno
Auf Branch master
Ihr Branch ist auf demselben Stand wie 'origin/master'.

nichts zu committen (benutzen Sie die Option -u, um unversionierte Dateien anzuzeigen) 

The current regexif (join(a:data) =~ "is behind") does not catch this .

IMHO it is better to use git to return the actual number of commits behind upstream on the current branch. This does for example following command

$ git rev-list HEAD..origin --count

(from https://stackoverflow.com/questions/29035858/git-show-number-of-commits-behind-upstream#comment79656552_29039305)

The correspending change to plugin/vim-outdated-plugins.vim would be

❯ git diff
diff --git a/plugin/vim-outdated-plugins.vim b/plugin/vim-outdated-plugins.vim
index 8d12f4d..0cb843f 100644
--- a/plugin/vim-outdated-plugins.vim
+++ b/plugin/vim-outdated-plugins.vim
@@ -1,5 +1,5 @@
 function! s:JobHandler(job_id, data, event) dict
-  if (str2nr(join(a:data)) =~ "is behind")
+  if (str2nr(join(a:data)) != 0)
     let g:pluginsToUpdate += 1
   endif
 endfunction
@@ -22,7 +22,7 @@ function! CheckForUpdates()

   " TODO check only activated plugins and not all downloaded
   for key in keys(g:plugs)
-    let job = async#job#start([ 'bash', '-c', "cd " . g:plugs[key].dir ." && git remote update && git status -uno"], s:callbacks)
+    let job = async#job#start([ 'bash', '-c', "cd " . g:plugs[key].dir ." && git remote update > /dev/null && git rev-list HEAD..origin --count"], s:callbacks)
   endfor
 endfunction
@semanser
Copy link
Owner

semanser commented Dec 2, 2018

Thanks, @kiryph! I really like your suggestion. It's done.

@semanser semanser added the enhancement New feature or request label Dec 2, 2018
@semanser semanser self-assigned this Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants