summaryrefslogtreecommitdiffstats
path: root/wsync
blob: 947f27a9bc4af7037056954d0f0abec00da0977f (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
#!/bin/zsh
mkdir -p /tmp/wsync
gproj=""

sproj=$1
trap logint INT

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

pread (){
        echo "[email protected]"
        echo
        echo -n ">_ "
        read
}
projdir="/home/raghavendra/Arch/Projects"
remotedir="/sate/gitole"

if [[ -n $sproj ]];then
    proj=$sproj
    pread "Syncing $proj"
    pushd $proj
    if /bin/grep -q "Unnamed repo" .git/description;then
        echo "Enter one line description"
        >| .git/description
        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
            print "Dirty repo"
            pread "Commit $proj  and then continue"
        done
        #git push --mirror -v $remotedir/$projname.git
        git push --mirror -v ssh://[email protected]/$remotedir:t/$projname.git
    fi
    popd
    echo "$proj done"

else
for proj in $projdir/*
do
    gproj="$proj"
    projname=${proj:t}
    echo "Syncing $proj"
    pushd $proj
    if /bin/grep -q "Unnamed repo" .git/description;then
        echo "Enter one line description"
        >| .git/description
        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
        if ! gitprompt 2>/dev/null;then
            print "Dirty repo"
            pread "Commit $proj  and then continue"
        fi
        git status
        git add -A
        git commit
        git push --mirror -v ssh://[email protected]/$remotedir:t/$projname.git
    fi
    popd
    echo "$proj done"
done
fi