Skip to main content
deleted 22 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Checks Checking if a git repository needneeds to be updated

I made a small Vim distribution that uses vundle. I decided to make a small function that checks if the repository must be updated. Here is the code:

""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
    "Get the current path and change the directory to update the good
    "repository
    let l:current_path = expand("<sfile>:p:h")
    let l:path = '~/.vim-mahewin-repository'
    exec 'cd' l:path

    let l:last_local_commit = system('git rev-parse HEAD')
    let l:last_remote_comit = system('git ls-remote origin -h refs/heads/master |cut -f1')

    if l:last_local_commit != l:last_remote_comit
        echo  'Need to be updated, launches updated'
        :!git pull `git remote` `git rev-parse --abbrev-ref HEAD`
    endif

    exec 'cd' l:current_path
endfunction

It's not very nice, but I have not found out how to do it better. I'm open to advice.

Thanks

Checks if a git repository need to be updated

I made a small Vim distribution that uses vundle. I decided to make a small function that checks if the repository must be updated. Here is the code:

""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
    "Get the current path and change the directory to update the good
    "repository
    let l:current_path = expand("<sfile>:p:h")
    let l:path = '~/.vim-mahewin-repository'
    exec 'cd' l:path

    let l:last_local_commit = system('git rev-parse HEAD')
    let l:last_remote_comit = system('git ls-remote origin -h refs/heads/master |cut -f1')

    if l:last_local_commit != l:last_remote_comit
        echo  'Need to be updated, launches updated'
        :!git pull `git remote` `git rev-parse --abbrev-ref HEAD`
    endif

    exec 'cd' l:current_path
endfunction

It's not very nice, but I have not found how to do better. I'm open to advice.

Thanks

Checking if a git repository needs to be updated

I made a small Vim distribution that uses vundle. I decided to make a small function that checks if the repository must be updated.

""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
    "Get the current path and change the directory to update the good
    "repository
    let l:current_path = expand("<sfile>:p:h")
    let l:path = '~/.vim-mahewin-repository'
    exec 'cd' l:path

    let l:last_local_commit = system('git rev-parse HEAD')
    let l:last_remote_comit = system('git ls-remote origin -h refs/heads/master |cut -f1')

    if l:last_local_commit != l:last_remote_comit
        echo  'Need to be updated, launches updated'
        :!git pull `git remote` `git rev-parse --abbrev-ref HEAD`
    endif

    exec 'cd' l:current_path
endfunction

It's not very nice, but I have not found out how to do it better. I'm open to advice.

Added vimscript tag. Tried to make sense of the first sentence.
Source Link

I made a small Vim distribution some it's very basic, that uses vundle. I decided to make a small function that checks if the repository must be updated. Here is the resultcode:

""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
    "Get the current path and change the directory to update the good
    "repository
    let l:current_path = expand("<sfile>:p:h")
    let l:path = '~/.vim-mahewin-repository'
    exec 'cd' l:path

    let l:last_local_commit = system('git rev-parse HEAD')
    let l:last_remote_comit = system('git ls-remote origin -h refs/heads/master |cut -f1')

    if l:last_local_commit != l:last_remote_comit
        echo  'Need to be updated, launches updated'
        :!git pull `git remote` `git rev-parse --abbrev-ref HEAD`
    endif

    exec 'cd' l:current_path
endfunction

It's not very nice, but I have not found how to do better. I'm open to advice.

Thanks

I made a small Vim distribution some it's very basic, that uses vundle. I decided to make a small function that checks if the repository must be updated. Here is the result:

""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
    "Get the current path and change the directory to update the good
    "repository
    let l:current_path = expand("<sfile>:p:h")
    let l:path = '~/.vim-mahewin-repository'
    exec 'cd' l:path

    let l:last_local_commit = system('git rev-parse HEAD')
    let l:last_remote_comit = system('git ls-remote origin -h refs/heads/master |cut -f1')

    if l:last_local_commit != l:last_remote_comit
        echo  'Need to be updated, launches updated'
        :!git pull `git remote` `git rev-parse --abbrev-ref HEAD`
    endif

    exec 'cd' l:current_path
endfunction

It's not very nice, but I have not found how to do better. I'm open to advice.

Thanks

I made a small Vim distribution that uses vundle. I decided to make a small function that checks if the repository must be updated. Here is the code:

""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
    "Get the current path and change the directory to update the good
    "repository
    let l:current_path = expand("<sfile>:p:h")
    let l:path = '~/.vim-mahewin-repository'
    exec 'cd' l:path

    let l:last_local_commit = system('git rev-parse HEAD')
    let l:last_remote_comit = system('git ls-remote origin -h refs/heads/master |cut -f1')

    if l:last_local_commit != l:last_remote_comit
        echo  'Need to be updated, launches updated'
        :!git pull `git remote` `git rev-parse --abbrev-ref HEAD`
    endif

    exec 'cd' l:current_path
endfunction

It's not very nice, but I have not found how to do better. I'm open to advice.

Thanks

Source Link

Checks if a git repository need to be updated

I made a small Vim distribution some it's very basic, that uses vundle. I decided to make a small function that checks if the repository must be updated. Here is the result:

""""""""""""""""""""""""""""""""""""""""""""""""""
"Update the repository
""""""""""""""""""""""""""""""""""""""""""""""""""
"A function to update if necessary
function! Get_update()
    "Get the current path and change the directory to update the good
    "repository
    let l:current_path = expand("<sfile>:p:h")
    let l:path = '~/.vim-mahewin-repository'
    exec 'cd' l:path

    let l:last_local_commit = system('git rev-parse HEAD')
    let l:last_remote_comit = system('git ls-remote origin -h refs/heads/master |cut -f1')

    if l:last_local_commit != l:last_remote_comit
        echo  'Need to be updated, launches updated'
        :!git pull `git remote` `git rev-parse --abbrev-ref HEAD`
    endif

    exec 'cd' l:current_path
endfunction

It's not very nice, but I have not found how to do better. I'm open to advice.

Thanks