欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 焦点 > 正点原子repo放到自己的git服务器

正点原子repo放到自己的git服务器

2025/1/17 22:26:40 来源:https://blog.csdn.net/lzw508170827/article/details/145189040  浏览:    关键词:正点原子repo放到自己的git服务器

atk-rk3568_android11

导出project-objects对应仓库

.repo/repo/repo list -n > project-object.txt

project-object.txt格式化,并通过gitolite.conf创建对应仓库

@atk-rk3568_android11_repo = atk-rk3568_android11/RKTools
@atk-rk3568_android11_repo = atk-rk3568_android11/device/common
@atk-rk3568_android11_repo = atk-rk3568_android11/device/generic/arm64
...
...
@atk-rk3568_android11_repo = atk-rk3568_android11/toolchain/benchmark
@atk-rk3568_android11_repo = atk-rk3568_android11/toolchain/pgo-profiles
@atk-rk3568_android11_repo = atk-rk3568_android11/tools/platform-compatrepo @atk-rk3568_android11_repoRW+CD = evan

获取路径和项目

.repo/repo/repo forall -c 'echo $REPO_PATH' > path.txt
.repo/repo/repo forall -c 'echo $REPO_PROJECT' > project.txt

脚本

#!/bin/bash# 常量定义
REP_URL="git@127.0.0.1:atk-rk3568_android11"
# 获取脚本的真实路径
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="$SCRIPT_DIR/script.log"# 日志函数
log() {echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
}# 显示帮助信息
usage() {cat << EOF
Usage: $0 [OPTIONS] <DIR> <SRC_DIR>This script initializes and pushes Git repositories based on paths and projects specified in files.Options:-h, --help     Display this help message and exit.Arguments:DIR            Directory containing path.txt and project.txt files.SRC_DIR        Source directory where the repositories are located.Example:$0 /path/to/dir /source/directoryThe script reads paths from 'path.txt' and corresponding projects from 'project.txt',
initializes a Git repository for each path, commits changes, and pushes to the remote repository.
EOF
}# 检查文件是否存在
check_files() {if [ ! -f "$1" ] || [ ! -f "$2" ]; thenlog "错误:找不到文件 $1$2"usageexit 1fi
}# 初始化并推送 Git 仓库
init_and_push() {local path="$1"local project="$2"local src_dir="$3"# 进入目录cd "$src_dir/$path" || { log "无法进入目录 $src_dir/$path"; return; }# 删除 .git 目录(如果存在)if [ -d ".git" ]; thenrm -rf .gitfi# 初始化 Git 仓库git init || { log "初始化 Git 仓库失败: $path"; return; }# 添加所有文件git add . || { log "添加文件失败: $path"; return; }# 提交更改git commit -m "first commit && create master branch" || { log "提交失败: $path"; return; }# 添加远程仓库git remote add origin "$REP_URL/$project" || { log "添加远程仓库失败: $path"; return; }# 推送至远程仓库git push -u origin master || { log "推送失败: $path"; return; }log "成功处理: $path : $project"
}# 主逻辑
main() {# 参数检查if [ $# -eq 1 ] && ([ "$1" == "-h" ] || [ "$1" == "--help" ]); thenusageexit 0fiif [ $# -ne 2 ]; thenlog "错误:参数数量不正确"usageexit 1fi# 获取参数DIR="$1"SRC_DIR="$2"# 文件路径path_file="$DIR/path.txt"project_file="$DIR/project.txt"# 检查文件是否存在check_files "$path_file" "$project_file"# 打开文件并逐行读取{while IFS= read -r path_line && IFS= read -r project_line <&3; do# 处理每一行init_and_push "$path_line" "$project_line" "$SRC_DIR"echo "==================================="done < "$path_file" 3< "$project_file"} 3<&-  # 关闭文件描述符3# 检查文件行数是否一致if [ "$(wc -l < "$path_file")" -ne "$(wc -l < "$project_file")" ]; thenlog "警告:$path_file$project_file 的行数不一致。"fi
}# 调用主逻辑
main "$@"

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com