Skip to content

Commit

Permalink
Move back to install
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <[email protected]>
  • Loading branch information
yubiuser committed Apr 23, 2023
1 parent 1cce064 commit 01b37b8
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 86 deletions.
86 changes: 0 additions & 86 deletions advanced/Scripts/piholeCheckout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,92 +38,6 @@ warning1() {
esac
}

get_available_refs() {
# Return available branches and tags
local directory
directory="${1}"
local output

cd "${directory}" || return 1
# Get reachable remote branches and tags, but store STDERR as STDOUT variable
output=$( { git ls-remote --heads --tags --quiet | cut -d'/' -f3- -; } 2>&1 )
# echo status for calling function to capture
echo "$output"
return
}

fetch_checkout_pull_branch() {
# Check out specified branch
local directory
directory="${1}"
local branch
branch="${2}"

# Set the reference for the requested branch, fetch, check it put and pull it
cd "${directory}" || return 1
git remote set-branches origin "${branch}" || return 1
git stash --all --quiet &> /dev/null || true
git clean --quiet --force -d || true
git fetch --quiet || return 1
checkout_pull_ref "${directory}" "${branch}" || return 1
}

checkout_pull_ref() {
# Check out specified branch/tag
local directory
directory="${1}"
local ref
ref="${2}"
local oldref
local ref_is_tag

cd "${directory}" || return 1

# Get current branch name.
oldref="$(git symbolic-ref --quiet HEAD)"

str="Switching to branch/tag: '${ref}' from '${oldref}'"
printf " %b %s" "${INFO}" "$str"

# check if the ref is a branch or a tag
if git show-ref -q --verify "refs/remotes/origin/$ref" 2>/dev/null; then
ref_is_tag=false
elif git show-ref -q --verify "refs/tags/$ref" 2>/dev/null; then
ref_is_tag=true
fi

if [ "$ref_is_tag" = true ]; then
# in case we want to checkout a tag we need explicitly create a new branch/reset the existing one
git checkout -B "${ref}" "refs/tags/${ref}" --quiet || return 1
printf "%b %b %s\\n" "${OVER}" "${TICK}" "$str"
else
# checkout a branch, this also sets tracking branch
git checkout "${ref}" --quiet || return 1
printf "%b %b %s\\n" "${OVER}" "${TICK}" "$str"
git_pull=$(git pull --no-rebase || return 1)
printf " %b %s\\n" "${INFO}" "${git_pull}"
fi

# Data in the repositories is public anyway so we can make it readable by everyone (+r to keep executable permission if already set by git)
chmod -R a+rX "${directory}"

return 0
}

fully_fetch_repo() {
# Add upstream branches/tags to shallow clone
local directory="${1}"

cd "${directory}" || return 1
if is_repo "${directory}"; then
git remote set-branches origin '*' || return 1
git fetch --tags --quiet || return 1
else
return 1
fi
return 0
}

checkout() {
local corerefs
local webrefs
Expand Down
87 changes: 87 additions & 0 deletions automated install/basic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,93 @@ check_download_exists() {
fi
}

fully_fetch_repo() {
# Add upstream branches/tags to shallow clone
local directory="${1}"

cd "${directory}" || return 1
if is_repo "${directory}"; then
git remote set-branches origin '*' || return 1
git fetch --tags --quiet || return 1
else
return 1
fi
return 0
}

get_available_refs() {
# Return available branches and tags
local directory
directory="${1}"
local output

cd "${directory}" || return 1
# Get reachable remote branches and tags, but store STDERR as STDOUT variable
output=$( { git ls-remote --heads --tags --quiet | cut -d'/' -f3- -; } 2>&1 )
# echo status for calling function to capture
echo "$output"
return
}

fetch_checkout_pull_branch() {
# Check out specified branch
local directory
directory="${1}"
local branch
branch="${2}"

# Set the reference for the requested branch, fetch, check it put and pull it
cd "${directory}" || return 1
git remote set-branches origin "${branch}" || return 1
git stash --all --quiet &> /dev/null || true
git clean --quiet --force -d || true
git fetch --quiet || return 1
checkout_pull_ref "${directory}" "${branch}" || return 1
}

checkout_pull_ref() {
# Check out specified branch/tag
local directory
directory="${1}"
local ref
ref="${2}"
local oldref
local ref_is_tag

cd "${directory}" || return 1

# Get current branch name.
oldref="$(git symbolic-ref --quiet HEAD)"

str="Switching to branch/tag: '${ref}' from '${oldref}'"
printf " %b %s" "${INFO}" "$str"

# check if the ref is a branch or a tag
if git show-ref -q --verify "refs/remotes/origin/$ref" 2>/dev/null; then
ref_is_tag=false
elif git show-ref -q --verify "refs/tags/$ref" 2>/dev/null; then
ref_is_tag=true
fi

if [ "$ref_is_tag" = true ]; then
# in case we want to checkout a tag we need explicitly create a new branch/reset the existing one
git checkout -B "${ref}" "refs/tags/${ref}" --quiet || return 1
printf "%b %b %s\\n" "${OVER}" "${TICK}" "$str"
else
# checkout a branch, this also sets tracking branch
git checkout "${ref}" --quiet || return 1
printf "%b %b %s\\n" "${OVER}" "${TICK}" "$str"
git_pull=$(git pull --no-rebase || return 1)
printf " %b %s\\n" "${INFO}" "${git_pull}"
fi

# Data in the repositories is public anyway so we can make it readable by everyone (+r to keep executable permission if already set by git)
chmod -R a+rX "${directory}"

return 0
}


clone_or_update_repos() {
# If the user wants to reconfigure,
if [[ "${reconfigure}" == true ]]; then
Expand Down

0 comments on commit 01b37b8

Please sign in to comment.