Skip to content

Instantly share code, notes, and snippets.

@DrI-T
Last active July 5, 2021 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrI-T/715b8887ed2c40328b0907f4ca7f0363 to your computer and use it in GitHub Desktop.
Save DrI-T/715b8887ed2c40328b0907f4ca7f0363 to your computer and use it in GitHub Desktop.
The mother of all code
#
# just after a ``git init`` you might want to do a
#
# sh 1stcommit.sh
# source GIT urls:
# - http://127.0.0.1:8080/ipfs/QmcpcVDXp31YsEBjZGieFF1abUTweuZk9EBxVWjKjx2qKp
# - http://127.0.0.1:8080/ipns/hologit.ml/anony/source.git
# - http://127.0.0.1:8080/ipfs/QmPwfV3f5PsfaPpRV6umWJzn8kjmneQY5ZAoKdBKqd8Yeu/8c8042a378f1db0ba13e0c8216590155.git
# - https://kmujb93x6y7bbzcqa345wdma5dsd480vgb4y7o796lhoi85phk43s.ipfs.dweb.link/itriphone/8c8042a378f1db0ba13e0c8216590155.git
#
git_url=https://ipfs.blockringtm.ml/ipns/hologit.ml/itrifone/8c8042a378f1db0ba13e0c8216590155.git
if echo -n "\e" | grep -q -e 'e'; then
e="-e" # bash needs a -e !
fi
gitdir=$(git rev-parse --absolute-git-dir)
top=$(git rev-parse --show-toplevel)
GIT_BY="$(git config user.name) <$(git config user.email)>"
#GIT_BY="$(git config committer.name) <$(git config committer.email)>"
git_tics=$(date +"%s %z")
treeid=$(sh -c 'echo -n "tree 0\0"' | openssl sha1 -r | cut -d' ' -f1)
echo tree: $treeid
cat > commit.txt <<EOT
tree $treeid
author $GIT_BY $git_tics
committer $GIT_BY $git_tics
EOT
len=$(stat -c %s commit.txt)
echo "commit $len\\0"
gitid=$(echo -n $e "commit $len\0" | cat - commit.txt | openssl sha1 -r | cut -d' ' -f1)
echo "gitid: $gitid"
shard=$(echo $gitid | cut -c-2)
objf=$(echo $gitid | cut -c3-)
echo objet: $gitdir/objects/$shard/$objf
if [ ! -d $gitdir/objects/$shard ]; then
mkdir -p $gitdir/objects/$shard
fi
echo -n "commit $len\0" | cat - commit.txt | pigz -9 -z > $gitdir/objects/$shard/$objf
echo $gitid > $gitdir/refs/heads/master
# logs/HEAD
qmlogshead=$(echo "0000000000000000000000000000000000000000 $gitid $GIT_BY $git_tics clone: from $git_url" | ipfs add -Q)
echo qmlogshead: $qmlogshead

From the source !

Cloning the source of all codes ...

Don't do a git init

Do instead :

git clone https://ipfs.io/ipfs/QmcpcVDXp31YsEBjZGieFF1abUTweuZk9EBxVWjKjx2qKp mycode
cd mycode
git log

gist=8c8042a378f1db0ba13e0c8216590155
qm=QmPwfV3f5PsfaPpRV6umWJzn8kjmneQY5ZAoKdBKqd8Yeu

#git clone https://kmujb93x6y7bbzcqa345wdma5dsd480vgb4y7o796lhoi85phk43s.ipfs.dweb.link/itriphone/8c8042a378f1db0ba13e0c8216590155.git
#git clone $(curl -sI https://git.io/JcoJr | grep -i -e location | cut -d' ' -f2)
git clone http://127.0.0.1:8080/ipfs/$qm/$gist.git

# we appreciate if you can pin this small repository for anyone to use, thank you
ipfs pin remote add --name=source $qm --service=pinata

# verify
qm=$(ipfs pin remote ls --service=pinata  | grep -w source | head -1 | sed -e "s/\t/ /g" | cut -d' ' -f1)
echo qm: $qm # is properly pinned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment