Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加Mercurial代码库相关的功能函数 #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions git-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,47 @@ function checkout_repo() {
git -C $TUNASYNC_WORKING_DIR show HEAD:repo > $TUNASYNC_WORKING_DIR/git-repo
}

# ---------------------------------------
# 20220511 Add Function for Initing git-remote-hg Script
# 2022 (C) LinuxBCKP
# ---------------------------------------
function init_git_remote_hg() {
mkdir /usr/bin
curl -o /usr/bin/git-remote-hg https://raw.githubusercontent.com/fingolfin/git-remote-hg/master/git-remote-hg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们不在脚本中下载可执行文件,我们会在 Dockerfile 中使用发行版的软件包。我们建议使用已经打包好的工具,例如直接使用 hg。

RUN apt-get update && \
apt-get install -y wget curl rsync lftp git jq python3-dev python3-pip yum-utils createrepo aria2 ack composer php-curl php-zip libnss-unknown

chmod +x /usr/bin/git-remote-hg
echo 'export PATH=/usr/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
git config --global core.notesRef refs/notes/hg
}

# ---------------------------------------
# 20220511 Add Function for Initing Mercurial Mirror
# 2022 (C) LinuxBCKP
# ---------------------------------------
function repo_init_hg() {
HGUPSTREAM="hg::"${UPSTREAM}
git clone --mirror $HGUPSTREAM $TUNASYNC_WORKING_DIR
}

# ---------------------------------------
# 20220511 Add Function for Updating Mercurial Mirror
# 2022 (C) LinuxBCKP
# ---------------------------------------
function update_repo_git_hg() {
HGUPSTREAM="hg::"${UPSTREAM}
cd $TUNASYNC_WORKING_DIR
echo "==== SYNC repo.git START ===="
git remote set-url origin "$HGUPSTREAM"
/usr/bin/timeout -s INT 3600 git remote -v update -p
head=$(git remote show origin | awk '/HEAD branch:/ {print $NF}')
[[ -n "$head" ]] && echo "ref: refs/heads/$head" > HEAD
git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')
sz=$(($sz*1024))
echo "Total size is" $(numfmt --to=iec $sz)
echo "==== SYNC repo.git DONE ===="
}

if [[ ! -f "$TUNASYNC_WORKING_DIR/HEAD" ]]; then
echo "Initializing repo.git mirror"
repo_init
Expand Down