Repo仓库搭建

1:创建远程Manifest仓库

ssh -p 29418 gerrit2 gerrit create-project -n mtk/manifest

2:初始化本地仓库Manifest仓库

git clone ssh://[email protected]:29418/mtk/manifest
创建default.xml并提交到服务器

3:从服务器初始化工程

repo init -u ssh://gerrit2/mtk/manifest --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=caf-stable

4:修改Repo, 适配空项目

.repo/repo/command.py

command.py的GetProjects会检测本地是否有该项目,如果么有不添加项目到结果集中,所以我们要把这段逻辑注释

      all_projects_list.extend(derived_projects.values())
      for project in all_projects_list:
        #if ((missing_ok or project.Exists) and
        #    project.MatchesGroups(groups)):
          result.append(project)

.repo/repo/subcmds/forall.py

该文件也会读取本地仓库的,如果没有则会直接报错退出

      p = subprocess.Popen(cmd,
                           #cwd = cwd,
                           shell = shell,
                           env = env,
                           stdin = stdin,
                           stdout = stdout,
                           stderr = stderr)
      #if not os.path.exists(cwd):
      #  if (opt.project_header and opt.verbose) \
      #  or not opt.project_header:
      #    print('skipping %s/' % project.relpath, file=sys.stderr)
      #  continue
      setenv('REPO_PROJECT', project.name)
      setenv('REPO_PATH', project.relpath)
      setenv('REPO_REMOTE', project.remote.name)
      #setenv('REPO_LREV', project.GetRevisionId())
      setenv('REPO_RREV', project.revisionExpr)
      setenv('REPO_I', str(cnt + 1))

5:建立本地仓库,提交本地仓库

init-commit.sh

#!/bin/bash
#set -e
#0: init
git init ${REPO_PATH}
GERRIT=mtk
ROOT_PATH=`pwd`
cd ${REPO_PATH}

#1: Commit Local
LOCAL_PATH=`pwd`
TMP_PATH=${ROOT_PATH}/tmp/${REPO_PATH}
count=0
for i in `find . -name  .gitignore`
do
  count=$(($count+1))
  TMP=${i}
  SOURCE=${LOCAL_PATH}${TMP:1}
  DEST=${TMP_PATH}${TMP:1}
  DEST_PATH=`dirname ${DEST}`
  echo mkdir -p $DEST_PATH
  mkdir -p $DEST_PATH
  echo cp ${SOURCE} $DEST
  cp ${SOURCE} $DEST
  rm -f $i
done

if [ ${count} != 0 ]; then
  echo Inner git add
  git add .
  cp ${TMP_PATH}/.gitignore ./
  cp ${TMP_PATH}/\* ./
fi

echo Outter git add
git add .
git commit -m "Init"

echo git commit
#2: Process Local None Project
git log
if [ $? != 0 ]; then
  echo empty so git commit
  git commit --allow-empty -m "init"
fi

#3: Create Remote Project
ssh gerrit2 gerrit create-project --name ${GERRIT}/${REPO_PROJECT}

#4: Push Remote
git remote add orgin ssh://gerrit2/${GERRIT}/${REPO_PROJECT}.git
git push orgin master:master
cd -

repo forall -c ./init-project.sh

PS: 特别注意.gitnore,对整个工程的影响

思路先放到一个地方, 然后再添加回来

#!/bin/bash
for i in `find . -name  .gitignore`
do
    echo $i
    rm -f $i
done

7:

8:

你可能感兴趣的:(Repo仓库搭建)