denisidoro/navi

Easy sync of downloaded cheatsheets

papanito opened this issue · 3 comments

Is your feature request related to a problem? Please describe.

As mentioned at auto-updating-repositories, so in case these repos are updated, one can easily get the latest and greatest.

Describe the solution you'd like

A command like navi repo sync would synchronize i.e. git pull the content of the repos

Adding of repos in should be basically a git clone of the cheatsheet repo rather doing a git clone to the tmp folder and then copying files over.

Describe alternatives you've considered

I currently use and adaption of your proposal,

#!/bin/bash
CHEATS_PATH=$(navi info cheats-path)

cd $CHEATS_PATH

for REPO_PATH in $(ls -d *); do
    echo "Get changes from $REPO_PATH"
    cd $REPO_PATH
    if [ -d ".git" ]; then
        DEFAULT_BRANCH=$(git branch -r | grep -Po 'HEAD -> \K.*$' | cut -d'/' -f2)
        echo $DEFAULT_BRANCH
        git pull -q origin $DEFAULT_BRANCH
    else
        repo_details=($(echo $REPO_PATH | sed  's/__/ /g'))
        repo_user=${repo_details[0]}
        repo_name=$(echo ${repo_details[1]} | cut -d'/' -f1)
        rm *
        git clone "https://github.com/${repo_user}/${repo_name}" .
    fi
    cd ..
done

Additional context
N/A

Thanks for opening your first issue here! In case you're facing a bug, please update navi to the latest version first. Maybe the bug is already solved! :)

Nice suggestion. It should be easy to implement.

I can't give an ETA, unfortunately.

I'll gladly review a PR, though.

The "donwside" of my soltuion, is that it assumes one is using github, but still I guess could be a start