repo 两次repo upload branch,怎么review

android(60)
使用 Git 作为代码管理工具,开发了 Gerrit 进行代码审核以便更好的对代码进行集中式管理,还开发了 Repo 命令行工具,对 Git 部分命令封装,将百多个 Git 库有效的进行组织。
清单库文件介绍
remotekorggit//172.16.1.31/
defaultkorggingerbread-exdroid-stable(project)remoterevision
projectpathname
projectcopyfilesrcdest
下载repo代码
$mkdir android2.3.4
$cd android2.3.4
$git clone
git://172.16.1.31/repo.git
androidreporeporeporepo
在本地开发的用户需要下载repo代码,在172.16.1.7服务器上开发的用户则不用下载repo代码,因为已经把repo脚本添加到了环境变量,执行repo init 就会附加的下载repo代码。
2.1 repo init
(下载repo并克隆manifest)
repo init &u URL
-u:URLmaniest
-m:manifestxml
-b:maniest
manifest.git
manifest.git.repo/manifests..repo/manifest.xml.repo/manifests/default.xml
manifestsxmlrepo init default.xml
git://172.16.1.31/manifest.git
android2.3.4.repo
git://172.16.1.31/manifest.git &m android.xml
android.xml.repo/manifest.xml.repo/manifests/android.xml
sync(下载代码)
[&project&…]
.repo/manifest.xmlrepo sync git
git remote update
remotefetch
git rebase
origin/branch
platform/build
start(创建并切换分支)
&newbranchname& [--all |
&project&…]
startgit checkout &b —allgit checkout &b git checkout
&b repo start
repo start&
stable& --all
gingerbread-exdroid-stablegingerbread-exdroid-stablestable
repo start&
stable& platform/build
platform/bionic
gingerbread-exdroid-stableplatform/buildplatform/bionicgingerbread-exdroid-stablestable
2.4 repo checkout(切换分支)
repo checkout
&branchname&&
[&project&…]
git checkout
repo checkout
crane-dev&
repo checkout
crane-dev&
platform/build&
platform/bionic
2.5 repo branches(查看分支)
repo branches
[&project&…]
repo branches platform/build
platform/bionic
2.6 repo diff(查看工作区文件差异)
[&project&…]
&git diff ,
diff&&&&&&&&&&&&&&&&&&&&&&&&&&&
---查看所有项目
repo diff platform/build
platform/bionic&
---只查看其中两个项目
2.7 repo stage(把文件添加到index表中)
--interactive
repo stage -i
[&project&…]
-igit add --interactive--interactive
2.8 repo prune(删除已经合并分支)
git branch
repo prune
[&project&…]
abandon(删除指定分支)
git branch
repo abandon
&branchname&
[&project&…]
2.10 repo status(查看文件状态)
diff-indexgit diff-filse
$repo/repo status
platform/bionic
platform/bionic
2.11 *repo
remote(设置远程仓库)
repo remote add
&remotename&&
[&project&…]&
repo remote rm
&remotename&&
[&project&…]
repo remote add org
ssh://172.16.1.31/git_repo
xmlbuildorg
2.12 *repo push
repo push org
&remotename& [--all
|&project&…]
2.13repo forall
repo forall
[&project&…] &c
&additional environment
variables:
REPO_PROJECT:
REPO_PATH:
REPO_REMOTE:
REPO_LREV:
REPO_RREV:manifestrevision
&-cshellshell
repo forall &c ‘echo $REPO_PROJECT’
$repo forall&&&c
‘echo $REPO_PATH’
3.13.2 merge()
mastertopicmaster
repo forall &p &c git merge topic
3.13.3 tag()
repo forall &c git tag
crane-stable-1.6
3.13.4 remote ()
REPO_PROJECT
forall &c ‘git remote add korg
ssh://xiong@172.16.31/$REPO_PROJECT.git’
repo forall &c git remote add
3.13.5 branch()
repo forall &c git branch
repo forall &c git checkout &b
3.1 repo grep
3.2 repo manifest
repo manifest &o
android.xml
3.3 repo version
3.4 repo upload
repo uploadgit push(Gerrit)SSH
repo upload [--re --cc]
{[&project&]… | --replace
&project&}
-h, --help:
--replace:
--re=REVIEWERS:
3.5 repo download
repo download {project change [patchset]}…
3.6 repo selfupdate
添加的remote指令
&在sumcmds中添加remote.py,程序如下:
# Copyright (C) 2009 The Android Open
Source Project
# Licensed under the Apache License,
Version 2.0 (the "License");
# you may not use this file except in
compliance with the License.
# You may obtain a copy of the
License at
&http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law
or agreed to in writing, software
# distributed under the License is
distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied.
# See the License for the specific
language governing permissions and
# limitations under the
import sys
from color import Coloring
from command import Command
from progress import Progress
class Remote(Command):
& common =
& helpSummary =
"View current topic branches"
& helpUsage =
&remotebranchname&
[&project&...]
& &%prog rm
&&remotebranchname&
[&project&...]
--------------
& def str_last(self
&for c in string:
&return last
& def Execute(self,
opt, args):
if not args:
&&sys.stderr, "error:..........wrong
command........"
&&sys.stderr, "Usage:repo remote add
&remotebranchname&
[&project&...]"
&&sys.stderr, " &
& &repo remote rm
&&remotebranchname&
[&project&...] " &
&&sys.stderr,
"................................"
operate=args[0]
#url = args[2]
&# branch_name=args[1]
if operate == "rm":
& &if not len(args)
& & &print
&&sys.stderr, "error:miss
remotebrancname"
& &branch_name=args[1]
& &projects = args[2:]
elif operate == "add":
& &if not len(args)
& & &print
&&sys.stderr, "error:miss
remotebranchname or url"
& &branch_name=args[1]
& &projects = args[3:]
&&sys.stderr, "error: the operand is
add or rm "
all = self.GetProjects(projects)
&&sys.stderr, all
pm = Progress('remote %s' % operate, len(all))
for project in all:
& &if operate == "add":
self.str_last(args[2])=="/":
args[2]+project.name+'.git'
& & & else
args[2]+'/'+project.name+'.git'
& & &url =
&pm.update()&
project.Remote(operate,branch_name,url):
&err.append(project)
& if len(err) == len(all):
&&sys.stderr, 'error: no project
remote &%s %s' % (operate,branch_name)
& & for p in err:
& & & print
&&sys.stderr,\
& "error: %s/: cannot remote %s %s " \
& % (p.relpath, operate,branch_name)
& sys.exit(1)
在preject.py中添加Remote(operate,branch_name,url)方法:
def Remote(self,operate,branch_name,url):
&"""Prune &topic branches already
merged into upstream.
&if url=="": & #rm
& &return GitCommand(self,
& &['remote', operate,
branch_name],
& &capture_stdout = True,
& &capture_stderr = True).Wait()
&else: &#add
& &return GitCommand(self,
& &['remote', operate,
branch_name,url],
& &capture_stdout = True,
& &capture_stderr = True).Wait()
&在subcmds中添加push.py,代码如下:
# Copyright (C) 2010
# Licensed under the Apache License,
Version 2.0 (the "License");
# you may not use this file except in
compliance with the License.
# You may obtain a copy of the
License at
&http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law
or agreed to in writing, software
# distributed under the License is
distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied.
# See the License for the specific
language governing permissions and
# limitations under the
import copy
import sys
from command import
InteractiveCommand
from editor import Editor
from error import UploadError,
from project import
ReviewableBranch
_ConfirmManyUploads(multiple_branches=False):
multiple_branches:
print "ATTENTION: One or more branches has an unusually high number
of commits."
print "ATTENTION: You are uploading an unusually high number of
& print "YOU
PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across
branches?)"
& answer =
raw_input("If you are sure you intend to do this, type 'yes':
").strip()
& return answer ==
def _die(fmt, *args):
& msg = fmt %
&&sys.stderr, 'error: %s' % msg
& sys.exit(1)
def _SplitEmails(values):
& result = []
& for str in
result.extend([s.strip() for s in str.split(',')])
class Push(InteractiveCommand):
& common =
& helpSummary =
"Upload changes for code review"
helpUsage="""
&remotebranchname&
{[&project&]... }
& helpDescription =
The '%prog' command is used to send
changes to the Gerrit Code
Review system. &It
searches for topic branches in local projects
that have not yet been published for
review. &If multiple topic
branches are found, '%prog' opens an
editor to allow the user to
select which branches to
'%prog' searches for uploadable
changes in all projects listed at
the command line.
&Projects can be specified either by name, or
a relative or absolute path to the
project's local directory. If no
projects are specified, '%prog' will
search for uploadable changes
in all projects listed in the
If the --reviewers or --cc options
are passed, those emails are
added to the respective list of
users, and emails are sent to any
new users. &Users
passed as --reviewers must already be registered
with the code review system, or the
upload will fail.
If the --replace option is passed the
user can designate which
existing change(s) in Gerrit match up
to the commits in the branch
being uploaded. &For
each matched pair of change,commit the commit
will be added as a new patch set,
completely replacing the set of
files and description associated with
the change in Gerrit.
Configuration
-------------
review.URL.autoupload:
To disable the "Upload ... (y/n)?"
prompt, you can set a per-project
or global Git configuration option.
&If review.URL.autoupload is set
to "true" then repo will assume you
always answer "y" at the prompt,
and will not prompt you further.
&If it is set to "false" then repo
will assume you always answer "n",
and will abort.
review.URL.autocopy:
To automatically copy a user or
mailing list to all uploaded reviews,
you can set a per-project or global
Git option to do so. Specifically,
review.URL.autocopy can be set to a
comma separated list of reviewers
who you always want copied on all
uploads with a non-empty --re
review.URL.username:
Override the username used to connect
to Gerrit Code Review.
By default the local part of the
email address is used.
The URL must match the review URL
listed in the manifest XML file,
or in the .git/config within the
project. &For example:
url = git:///project.git
review = /
autoupload = true
autocopy = ,my-team-
References
----------
Gerrit Code Review:
&/p/gerrit/
_SingleBranch(self, opt, branch):
project = branch.project
name = branch.name
remote = project.GetBranch(name).remote
key = 'review.%s.autoupload' % remote.review
answer = project.config.GetBoolean(key)
if answer is False:
& _die("upload blocked by %s = false" % key)
if answer is None:
& date = branch.date
& list = mits
& print 'Upload project %s/:' %
project.relpath
& print ' &branch %s (- commit%s,
& & len(list),
& & len(list) != 1 and 's' or
& for commit in list:
& & print ' &
& & & %s' %
& pushurl =
project.manifest.manifestProject.config.GetString('repo.pushurl')
& sys.stdout.write('to %s (y/n)? ' % (pushurl and
'server: ' + pushurl or 'remote') )
& answer = sys.stdin.readline().strip()
& answer = answer in ('y', 'Y', 'yes', '1',
'true', 't')
if answer:
& self._UploadAndReport(opt, [branch])
& _die("upload aborted by user")
_MultipleBranches(self, opt,remoebranch ,pending):
projects = {}
branches = {}
script = []
script.append('# Uncomment the branches to upload:')
for project, avail in pending:
& script.append('#')
& script.append('# project %s/:' %
project.relpath)
& for branch in avail:
& & name = branch.name
& & date = branch.date
& & list = mits
& &# print
&&sys.stdout, name
script.append('#')
& & script.append('
&branch %s (- commit%s, %s):' % (
& &##########3
len(list),
& & & len(list)
!= 1 and 's' or '',
& & for commit in list:
script.append('# & &
& & %s' % commit)
& & b[name] = branch
& projects[project.relpath] = project
& branches[project.name] = b
script.append('')
Editor.EditString("\n".join(script)).split("\n")
project_re = re.compile(r'^#?\s*project\s*([^\s]+)/:$')
branch_re = re.compile(r'^\s*branch\s*([^\s(]+)\s*\(.*')
project = None
for line in script:
& m = project_re.match(line)
& & name = m.group(1)
& & project =
projects.get(name)
& & if not project:
_die('project %s not available for upload', name)
& & continue
& m = branch_re.match(line)
& & name = m.group(1)
& & if not project:
_die('project for branch %s not in script', name)
& & branch =
branches[project.name].get(name)
& & if not branch:
_die('branch %s not in %s', name, project.relpath)
& & todo.append(branch)
if not todo:
& _die("nothing uncommented for upload")
self._UploadAndReport(opt, remoebranch,todo)
_UploadAndReport(self, opt,remoebranch,todo):
have_errors = False
for branch in todo:
& & # Check if there are local
changes that may have been forgotten
branch.project.HasChanges():
& key = 'review.%s.autoupload' %
branch.project.remote.review
& answer =
branch.project.config.GetBoolean(key)
& # if they want to auto upload, let's not ask
because it could be automated
& if answer is None:
sys.stdout.write('Uncommitted changes in ' + branch.project.name +
' (did you forget to amend?). Continue uploading? (y/n) ')
sys.stdin.readline().strip().lower()
& & & if a not
in ('y', 'yes', 't', 'true', 'on'):
&&sys.stderr, "skipping upload"
& & branch.uploaded = False
& & branch.error = 'User
& & continue
branch.project.UploadNoReview(opt,
remoebranch,branch=branch.name)
& & branch.uploaded = True
& except UploadError, e:
& & branch.error = e
& & branch.uploaded = False
& & have_errors = True
& except GitError, e:
&&sys.stderr, "Error: "+ str(e)
& & sys.exit(1)
print &&sys.stderr, ''
print &&sys.stderr,
'--------------------------------------------'
if have_errors:
& for branch in todo:
& & if not branch.uploaded:
& & & print
&&sys.stderr, '[FAILED] %-15s %-15s
&(%s)' % (
&branch.project.relpath + '/', \
&branch.name, \
&branch.error)
&&sys.stderr, ''
for branch in todo:
& & if branch.uploaded:
& & & print
&&sys.stderr, '[OK &
&] %-15s %s' % (
&branch.project.relpath + '/',
&branch.name)
if have_errors:
& sys.exit(1)
& def Execute(self,
opt, args):
if len(args)==0:
&&sys.stdout,"error:miss
remotebranchname"
&&sys.stdout, "Usage:repo push
&remotebranchname&
[&project&...]"
project_list = self.GetProjects(args[1:])
pending = []
remoebranch=args[0]
# if not create new branch, check whether branch has new
for project in project_list:
(project.GetUploadableBranch(project.CurrentBranch) is None):
& & continue
& branch =
project.GetBranch(project.CurrentBranch)
& rb = ReviewableBranch(project, branch,
branch.LocalMerge)
& pending.append((project, [rb]))
# run git push
if not pending:
&&sys.stdout, "no branches ready for
&# elif len(pending) == 1 and len(pending[0][1])
&# self._SingleBranch(opt, pending[0][1][0])
& self._MultipleBranches(opt,remoebranch
在preject.py中添加如下方法:UploadNoReview(opt,
remoebranch,branch=branch.name)
UploadNoReview(self, opt, remoebranch,branch=None):
& """If not review server defined, uploads the
named branch directly to git server.
&&sys.stdout, branch
& now_branch=branch
& if branch is None:
& & branch =
self.CurrentBranch
& if branch is None:
& & raise GitError('not currently
on a branch')
& branch = self.GetBranch(branch)
& if not branch.LocalMerge:
& & raise GitError('branch %s
does not track a remote' % branch.name)
&# if opt.new_branch:
&# & dest_branch =
branch.name
& dest_branch = branch.merge
& if dest_branch.startswith(R_TAGS):
& & raise GitError('Can not push
to TAGS (%s)! Run repo push with --new flag to create new feature
branch.' % dest_branch)
& if not dest_branch.startswith(R_HEADS):
& & dest_branch = R_HEADS +
dest_branch
& if not branch.remote.projectname:
& & branch.remote.projectname =
& & branch.remote.Save()
& # save git config branch.name.merge
&## if opt.new_branch:
& # &branch.merge =
dest_branch
& # &branch.Save()
& ref_spec = '%s:%s' % (R_HEADS + branch.name,
dest_branch)
& pushurl =
self.manifest.manifestProject.config.GetString('repo.%s.pushurl'
branch.remote.name)
& if not pushurl:
& & pushurl =
self.manifest.manifestProject.config.GetString('repo.pushurl')
& if not pushurl:
& & pushurl =
branch.remote.name
& & pushurl = pushurl.rstrip('/')
+ '/' + self.name
& & remote =
self.manifest.remotes.get(branch.remote.name)
& & if remote and
remote.autodotgit is not False:
& & & pushurl +=
& cmd = ['push']
&&sys.stdout, now_branch+'now'
& cmd.append(remoebranch)
& cmd.append(now_branch)
&&sys.stdout, "push"+"
"+self.name+':'
& if GitCommand(self, cmd).Wait() != 0:
& & raise UploadError('Upload
& if branch.LocalMerge and
branch.LocalMerge.startswith('refs/remotes'):
self.bare_git.UpdateRef(branch.LocalMerge,
& & R_HEADS + branch.name)
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:69592次
积分:1470
积分:1470
排名:第19586名
原创:36篇
转载:51篇
评论:26条
(1)(3)(2)(80)(1)(1)1013人阅读
Android源码(23)
由于Android源码太过庞大,Google在Git基础上外包一层,是为repo,用来方便地对项目进行管理、开发。
所以,往服务器上传代码。不再是git commit后git push,而是
repo upload如果这时出错:
no branches ready for upload
并且之前也是在自己的branch上进行的操作,那么原因就是采用了错误的分支branch创建方法:repo错误的branch创建方法:
git branch branch-name有了repo,创建分支:
repo start branch-name project-name如此,就不在报上述错误。
两种branch创建方式,生成的config文件是有区别的,可以:
cat ./git/config看下。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:70428次
积分:1745
积分:1745
排名:第16059名
原创:104篇
评论:19条
(1)(4)(3)(3)(2)(2)(2)(4)(5)(2)(3)(5)(2)(2)(4)(1)(2)(4)(7)(4)(1)(4)(4)(3)(1)(9)(4)(13)(10)博客访问: 1725209
博文数量: 431
博客积分: 12926
博客等级: 上将
技术积分: 4438
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: LINUX
关于repo的一些命令&1、怎样在代码文件夹下所有git库都建立分支? repo start --all 2、怎样删除代码文件夹下所有git库的分支? repo abandon *1和2其实就是相反的动作3、怎样知道代码文件夹下都改动了那些? repo diff4、怎样把我的提交上传的gerrit上? repo upload如果出现文件就把要提交的部分前面的#去掉5、不想同步所有代码,只想同步一部分? repo sync
……6、repo upload以后后悔了,需要再修改一些?(1)在原有分支上修改文件(2)git commit --amend&(3)repo upload --replace (4)出现文件以后去掉第1行的#,中括号里面填上 change-id关于Git的一些命令&1、repo init的时候我没有改用户名和email,现在发现不对了怎么办?git config --global user.name "" ----修改用户名git config --global user.email "" ----修改emailgit config --list ----查看修改2、想查看以前都有哪些提交? git log3、想查看以前的两次提交有什么区别? git diff
4、想查看以前代码,但是现在修改的不能动 git checkout 5、想回到以前,现在修改的都不要了 git reset --hard 6、想把自己的修改提交到本地的git库里?git add git commit -m ""7、提交以后后悔了,文件还是要修改后的,只是不想要这次提交? git reset HEAD~18、提交以后发现少add了一个文件?git add git commit --amend9、git add了很多文件,发现其中一个不想提交? git reset HEAD 10、只想同步代码里的一个文件? git pull 11、只删除中间的一个commit对应的修改,其他不变 git revert 关于从A代码里面打包,放到B代码的问题两种方法:1)在A代码里面,$git diff
> A.patch在B代码里面,$git apply A.patch有冲突解决冲突。打开对应修改的文件发现就已经被修改了。--这个方法的缺点是对应A代码的commit是不会加到B代码上的。2)在A代码里面,$git format-patch -
-o -,x填一个数字,表示从倒数第几个commit开始运行完成就能在下看见个patch,对应一个commit一个patch 在B代码里面,$git am /*.patch,就把所有的patch加到B代码里面了。 --这个方法可以把A代码里面对应的commit都加到B代码上。
阅读(12066) | 评论(0) | 转发(2) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。

我要回帖

更多关于 repo upload 详解 的文章

 

随机推荐