Skip to content

Commit

Permalink
Merge pull request #33 from anatawa12/support-ref
Browse files Browse the repository at this point in the history
feat: add support for direct refs or commits doesn't belong to any branches
  • Loading branch information
anatawa12 authored Apr 2, 2024
2 parents 3c999dd + c45d6d4 commit 3326429
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions misskey-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,21 @@ function install() {
function git_clone() {
echo "";
tput setaf 3; echo "Process: clone git repository;"; tput setaf 7;
sudo -iu "$misskey_user" git clone --no-single-branch --recursive "$git_repository" "$misskey_directory";
sudo -iu "$misskey_user" git -C "$misskey_directory" checkout "$git_branch";
# git clone --depth 1 --branch "$git_branch" "$git_repository" "$misskey_directory" --recursive;
# but supports any branch, tag, commit hash, or remote ref
sudo -iu "$misskey_user" mkdir -p "$misskey_directory"
sudo -iu "$misskey_user" git init "$misskey_directory"
sudo -iu "$misskey_user" git -C "$misskey_directory" remote add origin "$git_repository"
sudo -iu "$misskey_user" git -C "$misskey_directory" fetch --depth 1 origin "$git_branch"
if [ -f "$misskey_directory/.git/refs/remotes/origin/$git_branch" ]; then
# if the fetched ref is a branch, check it out
sudo -iu "$misskey_user" git -C "$misskey_directory" checkout "$git_branch"
else
# if the fetched ref is a tag, commit hash, or remote ref, create a detached HEAD
sudo -iu "$misskey_user" git -C "$misskey_directory" checkout --detach FETCH_HEAD
fi
# initialize submodules recursively
sudo -iu "$misskey_user" git -C "$misskey_directory" submodule update --init --recursive --depth 1
}

#Create misskey config file
Expand Down

0 comments on commit 3326429

Please sign in to comment.