opengist
· 863 B · Text
Raw
#! /bin/sh
# create an opengist file and push it to the server
#
# alexlehm/at/gmail.com
TMPDIR=git_gist.$$
if [ `expr "$1" : "https://"` = 0 ]
then
URL=https://alexlehm@gist.tilde.green/init
mkdir $TMPDIR
cd $TMPDIR
git init
git config credential.helper store
# if default branch is main, change to master, otherwise we confuse opengist
git remote add origin $URL
cd ..
if [ $# = 0 ]
then
cat >$TMPDIR/file.txt
else
cp $* $TMPDIR/
fi
cd $TMPDIR
git add .
git commit -a -m "automatic upload"
git branch master
git checkout master
git push -u origin master
cd ..
else
URL=$1
shift
git clone $URL $TMPDIR
if [ $# = 0 ]
then
cat >$TMPDIR/file.txt
else
cp $* $TMPDIR/
fi
cd $TMPDIR
git commit -a -m "automatic upload"
cd ..
fi
rm -rf $TMPDIR/
1 | #! /bin/sh |
2 | |
3 | # create an opengist file and push it to the server |
4 | # |
5 | # alexlehm/at/gmail.com |
6 | |
7 | TMPDIR=git_gist.$$ |
8 | |
9 | if [ `expr "$1" : "https://"` = 0 ] |
10 | then |
11 | URL=https://alexlehm@gist.tilde.green/init |
12 | mkdir $TMPDIR |
13 | cd $TMPDIR |
14 | git init |
15 | git config credential.helper store |
16 | # if default branch is main, change to master, otherwise we confuse opengist |
17 | git remote add origin $URL |
18 | |
19 | cd .. |
20 | if [ $# = 0 ] |
21 | then |
22 | cat >$TMPDIR/file.txt |
23 | else |
24 | cp $* $TMPDIR/ |
25 | fi |
26 | |
27 | cd $TMPDIR |
28 | git add . |
29 | git commit -a -m "automatic upload" |
30 | git branch master |
31 | git checkout master |
32 | git push -u origin master |
33 | cd .. |
34 | else |
35 | URL=$1 |
36 | shift |
37 | git clone $URL $TMPDIR |
38 | if [ $# = 0 ] |
39 | then |
40 | cat >$TMPDIR/file.txt |
41 | else |
42 | cp $* $TMPDIR/ |
43 | fi |
44 | |
45 | cd $TMPDIR |
46 | git commit -a -m "automatic upload" |
47 | cd .. |
48 | fi |
49 | |
50 | rm -rf $TMPDIR/ |
51 | |
52 |