summaryrefslogtreecommitdiffstats
path: root/wsync
blob: 33b5e7debbc4979a034386238e327e8478509af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/zsh
mkdir -p /tmp/wsync
gproj=""
projdir="/home/raghavendra/Arch/Projects"
remotedir="/sate/gitole"

sproj=$1
trap logint INT

logint(){
    echo "$gproj" >| /tmp/.wsync
    exit 3
}

pread (){
        echo "[email protected]"
        echo
        echo -n ">_ "
        read
}
rpush(){

    print "\n\n"
    proj=$1
    pushd $proj
    projname=${proj:t}
    if /bin/grep -q "Unnamed repo" .git/description;then
        echo "Enter one line description"
        >| .git/description
        mkdir -p $remotedir/$proj:t/
        cp .git/description $remotedir/$proj:t/
    fi

    if [[ ! -d $remotedir/$projname.git ]];then
        git clone --mirror -v $proj  /tmp/wsync/$projname.git
        scp -q -r /tmp/wsync/$projname.git  [email protected]:/$remotedir:t/
    else
        while ! gitprompt 2>/dev/null;do
            echo 
            print "Dirty repo"
            pread "Commit $proj  and then continue"
            git diff 
            echo "Stop ?"
            read -q || {
                git add -A
                git commit -v  || {
                    git reset --soft
                    continue
                }   
            }
        done
        git push --mirror -v ssh://[email protected]/$remotedir:t/$projname.git
    fi
    popd
    print "=============================================================="
    print "\n\n"
}


if [[ -n $sproj ]];then
    proj=$sproj
    proj="$HOME/Arch/Projects/$proj"
    pread "Syncing $proj"
    rpush $proj
    echo "$proj done"

else
    for proj in $projdir/*
    do
        gproj="$proj"
        projname=${proj:t}
        echo "Syncing $proj"
        rpush $proj
        echo "$proj done"
    done
fi