git 提交到 gerrit

git 提交到 gerrit,第1张

概述git 提交到 gerrit

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

#!/usr/bin/env python#Coding:utf-8''''''import osimport sysoriginname = "origin"versionInfo = """调用方式:1.将 ssrepo 复制到 '~/bin' 目录下2.sudo chmod +x ssrepo    为 ssrepo 增加可执行权限 3.将 '~/bin' 加入到环境变量 PATH 中提交代码:1.git add 将要提交修改加入暂存区2.git commit -s 提交修改3.ssrepo sync 同步服务器代码到当前所在分支,重排提交序列4.ssrepo upload 提交当前分支到服务器 master 分支注意事项:1.可使用 ssrepo push 替代 ssrepo sync 和 ssrepo upload 一次完成同步和提交 *** 作--= version info =--version 0.41.修正新文件位于文件夹中因文件夹不存在导致 sync时异常结束的BUGversion: 0.31.修正同步时将其他用户删除的文件加入cache中,而导致代码中出现多余的无用文件的问题2.增加 push 方法,使用 ssrepo push 调用,自动进行 sync 后进行 upload。version: 0.21.修正master分支pull时出现 非快进式错误提示2.修正再没有进行git stash 时,错误的调用了 git stash pop 的问题"""def hasversion(filename) :	logline = os.popen('git log {0}'.format(filename)).readlines()	return len(logline) > 0def removeCache(cachepath):	for parent,dirnames,filenames in os.walk(cachepath):			for filename in filenames:									srcpath = (os.path.join(parent,filename)) 			targetpath = srcpath[1:]						if os.path.exists(targetpath):				pass			else:				targetDir = os.path.abspath(os.path.join(targetpath,'..'))				if os.path.exists(targetDir):					pass				else :					os.makedirs(targetDir)				os.rename(srcpath,targetpath)				if hasversion(targetpath) :					#print('hasversion need delete ' + targetpath)					os.popen('rm {0}'.format(targetpath)).readlines()				else :					print("no version new file " +targetpath)	os.popen('rm -rf '+cachepath).readlines()def sync(needMV = True):	#print('--origin--')	HASHCODES = os.popen('git log {0} --format="%H"'.format(originname)).readlines()	#for x in HASHCODES:	#	print(x)	localcodes = [];	#print('--local--')	LOCALHASHCODES = os.popen('git log --format="%H"').readlines()	#for x in LOCALHASHCODES:	#	print(x)	#print('--same--')	tmp = [val for val in HASHCODES if val in LOCALHASHCODES]	#for t in tmp :	#	print(t)	HASHCODE = tmp[0].strip()	print("last same code is " + HASHCODE)	for CODE in LOCALHASHCODES :		CODE = CODE.strip()		if ( cmp(CODE,HASHCODE) == 0) :			break		else :			localcodes.append(CODE)	cherryCount = len(localcodes)	print("need cherry count is {0}".format(cherryCount) )	for c in localcodes : 		print ("need cherry code " + c)	localcodes.reverse()	line = os.popen('git branch -a | grep "*"').readlines()	branchname = line[0].strip('*').strip()	print('local branch is ' + branchname)	stash = os.popen('git stash').readlines()	os.popen('git reset '+HASHCODE ).readlines()	if (needMV) :		os.popen('mv src 1src').readlines()		os.popen('mv res 1res').readlines()		os.popen('mv libs 1libs').readlines()	os.popen('git reset --hard').readlines()	if cmp(branchname,'master') == 0:		os.popen('git pull').readlines()	else :		os.popen('git pull {0} master:{1}'.format(originname,branchname)).readlines()	for c in localcodes : 		os.popen('git cherry-pick ' + c ).readlines()		print ('cherry-pick ' + c)	if len(stash) > 1 :		print('stash pop')		os.popen('git stash pop').readlines()	else :		print('stash is clear')	removeCache('1src')	removeCache('1res')	removeCache('1libs')			def upload():	line = os.popen('git branch -a | grep "*"').readlines()	branchname = line[0].strip('*').strip()	print('the branch "{0}" will be push '.format(branchname))	os.popen('git push {0} {1}:refs/for/master'.format(originname,branchname)).readlines()def getoriginInfo():	originInfoline = os.popen('git remote -v').readlines()	for originInfo in originInfoline:		originInfo = originInfo.strip()		#print(originInfo)		if(originInfo.endswith('(push)')) :			#print(originInfo)			infos = originInfo.split('\t',2)			originname = infos[0]			#print(infos[1])			port = infos[1].split(':',3)[2].split('/')[0]			servername = infos[1].split('@',2)[1].split(':')[0]			username = infos[1].split('//',2)[1].split('@')[0]			#print(" --== origin info ==--")			#print(" originname : {0}".format(originname))			#print(" servername : {0}".format(servername))				#print(" serverPort : {0}".format(port))			#print(" username   : {0}".format(username))			#scpstr = "scp -p {0} {1}@{2}:hooks/commit-msg .git/hooks/".format(port,username,servername)#			print(scpstr)def main():	workarg = sys.argv[-1].strip()	print('method "{0}"'.format(workarg))	fetchline = os.popen('git fetch').readlines()	if (len(fetchline) > 0 and fetchline[0].startswith('fatal')) or os.path.exists('src') is False :		print ('please make Terminal to code root path !!!')	else :		getoriginInfo()		if cmp(workarg,'sync') == 0 :			sync()		elif cmp(workarg,'upload') ==0 :			upload()		elif cmp(workarg,'push') ==0 :			print(" sync start...")			sync()			print("")			print(" upload start...")			upload()		elif cmp(workarg,'continue') ==0 :			print(" continue sync") 			sync(False)			print("")		else :			print("*************************************************************")			print("")			print('method not find !!!   please use "sync" or "upload" or "push"')			print("")			print("----------------------    help    --------------------------")			print(versionInfo)			print("*************************************************************")			print("")if __name__ == '__main__':	main()

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的git 提交到 gerrit全部内容,希望文章能够帮你解决git 提交到 gerrit所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1199222.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存