zoukankan      html  css  js  c++  java
  • Gerrit 大量代码提交流程优化

    # Gerrit 大量代码提交流程优化

    背景

    本文适用于 提交大量初始代码 的场景(仓库版本的早期)。

    有时候提交大量代码到Gerrit的时候会提示:

    $ git push
    Counting objects: 512996, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (482705/482705), done.
    Writing objects: 100% (512996/512996), 2.61 GiB | 9.46 MiB/s, done.
    Total 512996 (delta 123942), reused 624 (delta 117)
    remote: Resolving deltas: 100% (123942/123942)
    remote: Counting objects: 512999, done
    remote: Processing changes: refs: 1, done
    To ssh://xx@xx:29418/xxx
     ! [remote rejected] master -> refs/for/master (commit bb5b175: Exceeding maximum number of files per change (499908 > 100000))
    error: failed to push some refs to 'ssh://xx@xx:29418/xxx'
    

    此后就需要花费大量的人力到提交代码上,降低开发效率;因此有必要解决这样的问题。

    注意,用这种方法提交的代码不会在Gerrit-Code Review区域显示,因此本文最适用于 提交初始代码 的场景,为了规范技术管理,其他场景的操作最好向管理员报备后再操作

    做法

    思路很简单,提交的时候绕过refs/for/ 和refs/heads/即可。

    在Gerrit中添加权限

    入口:点击Gerrit仓库,找到AccessEditADD REFERENCE

    为了以防万一,添加一个组,赋予强推权限。

    Gerrit新建强推组:syncer

    > 实际上,下面的权限是我先通过`git push --force`以后,根据错误提示再一步步配置了Gerrit的权限得到的。

    1、refs/heads/master

    • Push:ALLOW - sysncer - Allow pushing with or without force
    • Forge Committer Identity:ALLOW - sysncer
    • Forge Author Identity:ALLOW - sysncer

    2、refs/remotes/origin/master

    • Create Reference:ALLOW - sysncer
    • Delete Reference:ALLOW - sysncer

    3、refs/for/refs/heads/master

    • Create Reference:ALLOW - sysncer
    • Delete Reference:ALLOW - sysncer

    提交方式

    0、找到Gerrit的仓库地址,${Gerrit-repo}

    1、拉取需要提交的Gerrit代码仓库:

    git clone ${Gerrit-repo}
    

    2、提交

    注意,一般的Gerrit仓库要提交代码之前需要:config refs/heads/*:refs/for/*,但是在这里不需要。

    git push
    
    # 必要时,使用强推命令。
    git push --force --mirror 
    

    结果:

    Counting objects: 136002, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (125500/125500), done.
    Writing objects: 100% (136002/136002), 971.01 MiB | 9.36 MiB/s, done.
    Total 136002 (delta 27908), reused 0 (delta 0)
    remote: Resolving deltas: 100% (27908/27908)
    remote: Counting objects: 136015, done
    remote: Processing changes: refs: 1, done
    To ssh://xx@xx:29418/xx
       610d066..c3d6d87f master -> master
    

    3、验证:在另外的地方git clone下来看看git log记录,看看提交信息是否健全。

  • 相关阅读:
    从FLC中学习的设计模式系列创建型模式(5)原型
    WP7应用开发笔记技巧 使用VisualState布置屏幕方向处理
    从FLC中学习的设计模式系列创建型模式(4)建造者
    从FLC中学习的设计模式系列结构型模式(1)适配器
    模拟Windows phone 开始菜单的瓦片动画
    解决log4net在.net 4.0 ClientProfile下无法使用
    从FLC中学习的设计模式系列创建型模式(1)单例
    从FLC中学习的设计模式系列创建型模式(2)抽象工厂
    WP7应用开发笔记(9) 应用程序栏
    同步上下文 SynchronizationContext 学习笔记
  • 原文地址:https://www.cnblogs.com/schips/p/a_way_to_optimization_of_push_a_piece_of_commit_in_gerrit.html
Copyright © 2011-2022 走看看