以从github导入coding.net为例:
#1、克隆库 git clone https://github.com/antirez/redis.git --bare #2、上传 cd redis.git git push https://git.coding.net/jiong/redis.git --all #3、推送全部标签 git push https://git.coding.net/jiong/redis.git --tags
Learn and share.
以从github导入coding.net为例:
#1、克隆库 git clone https://github.com/antirez/redis.git --bare #2、上传 cd redis.git git push https://git.coding.net/jiong/redis.git --all #3、推送全部标签 git push https://git.coding.net/jiong/redis.git --tags
VirtualBox有四种联网方式:
NAT:
虚拟机通过网络地址转换协议来访问宿主机网络,虚拟机可以访问宿主机可以访问的所有网络
宿主机和虚拟机之间无法通讯
而在宿主机局域网其他主机看来,虚拟机是不存在的
虚拟机之间不可以相互访问
Bridged:
虚拟机通过桥接,把自己虚拟为宿主机同一局域网的一台设备,虚拟机可以访问宿主机可以访问的所有网络
对于宿主机来说,虚拟机就是同一局域网的一台设备
而在宿主机局域网其他主机看来,虚拟机就是同一局域网的一台设备
虚拟机之间可以相互访问
HostOnly:
虚拟机宿主机可以相互访问,默认虚拟机不可以访问宿主机所在网络(宿主机可以共享网络给虚拟机,但一般不会这么用)。
虚拟机之间可以相互访问
Internal:
只有虚拟机之间可以相互访问。
具体情况如下(假设网段设置都正确):
通讯 | Internal | HostOnly | NAT | Bridge |
虚拟机到宿主机 | NO | YES | YES | YES |
宿主机到虚拟机 | NO | YES | NO | YES,部分网络服务受限 |
虚拟机到其他主机 | NO | NO | YES | YES,部分网络服务受限 |
其他主机到虚拟机 | NO | NO | NO | YES |
虚拟机到虚拟机 | YES | YES | NO | YES |
#debain8 apt-get remove --auto-remove libgtk-3-common #debain6 apt-get remove --auto-remove libgtk2.0-common
Debain6已经没有更新支持了
#会提示找不到更新源 apt-get update
为了继续按照软件,需要做两件事情:
1、修改/etc/apt/sources.list文件
# deb http://ftp.debian.org/debian/ squeeze-updates main contrib # deb http://http.us.debian.org/debian/ squeeze contrib non-free main # deb-src http://ftp.debian.org/debian/ squeeze-updates main contrib deb http://archive.debian.org/debian squeeze main deb http://archive.debian.org/debian squeeze-lts main
2、增加/etc/apt/apt.conf文件
Acquire::Check-Valid-Until false;
昨天,公司一位同事遇到了十分神奇的一件事情,就是ibaits在应该调用A类A1方法时,ibatis会调用到B类的B1方法。
几个人查了半天,没发现情况。
最后细心的小江同学发现,是有一个接口文件的声明,与映射文件中的参数类型不一致造成的。
好坑啊。。。
下面的两部分,分别设置了java及javadoc的编码为UTF-8
build.gradle
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } tasks.withType(Javadoc) { options.encoding = 'UTF-8' }
前面做测试,生成了很多错误的review request。
但没有找到可以批量删除的工具,于是自己写了一个。
deleterequest.py
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2016-11-24 @author: Hansen 获取指定svn文件夹下,指定svn版本的注释 ''' import os import sys #获取指定svn版本的注释 def del_rb_request(rid1,rid2): for rid in range(rid1,rid2): cmd='curl -X DELETE --header "Authorization: token API_TOKEN" http://127.0.0.1/api/review-requests/'+str(rid)+'/' print(cmd) logs = os.popen(cmd.encode()).readlines() for log in logs: print(log) #start here del_rb_request(0,86)
接上一篇。
1、脚本写了没多久,但郁闷的是测通上面的脚本我花了很久,后来发现主要是字符集的问题。
我用的是Debian默认字符集为UTF8,python2.7默认字符集为ASCII。
后面,设置了python的字符集默认为UTF8,第一篇的脚本才测通了。
/usr/lib/python2.7/sitecustomize.py
# install the apport exception handler if available import sys sys.setdefaultencoding('UTF8') try: import apport_python_hook except ImportError: pass else: apport_python_hook.install()
2、然后发现RBT貌似不支持UTF8的中文参数,反正我没有测通,好吧,自己写了一个脚本将SVN上的中文注释更新到mysql中。
说明一下,RBT的这个问题,我已经向社区提交Bug了,亲测补丁有效,大家等待下一版本就好了。
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2016-11-24 @author: Hansen 用于更新rb的说明 ''' import sys import datetime import MySQLdb import nsvnutils #记录日志 def nlog(logpath,msg): fo = open(logpath,'a+') try: fo.write(msg+'\n') finally: fo.close() #更新rb的reviewrequest说明 def update_rb_comment(): #获取连接 try: connection=MySQLdb.connect(user='user',passwd="passwd",host='127.0.0.1',port=3306,db='db',charset='utf8') subconnection=MySQLdb.connect(user='user',passwd="passwd",host='127.0.0.1',port=3306,db='db',charset='utf8') #print('mysql connection ok') nlog('/mnt/rb/sql.log','mysql connection ok') except Exception as ex: #print(str(ex)) nlog('/mnt/rb/sql.log',str(ex)) return #获取需要处理的数据 try: cursor=connection.cursor() subcursor=subconnection.cursor() sql="select id,summary from reviews_reviewrequest r where r.description='' or r.description is null" cursor.execute(sql) #print('mysql select ok') nlog('/mnt/rb/sql.log','mysql select ok') for row in cursor.fetchall(): rid=str(row[0]) ss=row[1].split('_Rev') if len(ss)==2: nsvnutils.get_repo_name(ss[0]) comment=nsvnutils.get_svn_log(ss[1]) commiter=nsvnutils.get_svn_commiter(ss[1]) subsql="update reviews_reviewrequest r set r.description='"+commiter+"_"+comment+"' where r.id="+rid #print(subsql) nlog('/mnt/rb/sql.log',subsql) subcursor.execute(subsql) else: #print('skiping id='+rid+' summary='+row[1]) nlog('/mnt/rb/sql.log','skiping id='+rid+' summary='+row[1]) subconnection.commit() except Exception as ex: #print(str(ex)) nlog('/mnt/rb/sql.log',str(ex)) return finally: cursor.close() subcursor.close() connection.close() subconnection.close() #start here nlog("/mnt/rb/sql.log", 'Starting job on '+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) update_rb_comment() nlog("/mnt/rb/sql.log", 'Ending job on '+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
3、建立定时任务,执行脚本
crontab -l #10分钟运行一次 */10 * * * * /home/neohope/scripts/updatedb.py
公司的SVN服务器是在Windows上的,ReviewBoard是在Linux虚拟服务器上的。
好吧,主要是历史原因了哦。。。
解决思路是,利用SVN的post-commit钩子,在提交后,将版本号存到一个文件中。
在Linux服务器中,定时去扫描这些文件,有变动的话,则利用RBTools提交请求。
1、Windows中用post-commit钩子获取版本号
post-commit.bat
@echo off SET REPOS=%1% SET REV=%2% SET RPATH=PATH_TO_STORE_FILE CALL :getfilename %REPOS% echo %REV% >> %RPATH%\%FNAME%.txt :success exit 0 :getfilename set FNAME=%~nx1
2、Linux中用python脚本扫描文件变动
runme.py
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2016-11-24 @author: Hansen 遍历监视文件夹下所有的txt文件 当文件多余两行时,对于每一行,调用rbt生成review请求 最后,只保留最后一行 ''' import os import sys import datetime import nsvnutils #记录日志 def nlog(logpath,msg): fo = open(logpath,'a+') try: fo.write(msg) finally: fo.close() #创建rbt命令,并调用命令 def create_rbt_command(repo, revision1, revision2, logpath): title = repo+"_Rev"+revision1 comment = nsvnutils.get_svn_log(revision1) commiter = nsvnutils.get_svn_commiter(revision1) #rbt好像不支持utf8参数,因此用更新db的方式添加注释 cmd = 'rbt post -p --repository ' +repo+" --repository-type svn --server http://127.0.0.1 --api-token API_TOKEN --summary "+title+' '+revision1 fo = open(logpath,'a+') try: fo.write('adding rbt job on '+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')+'\n') fo.write('PWD is '+os.getcwd()+'\n') fo.write('CMD is '+cmd+'\n') logs = os.popen(cmd.encode('UTF8')).readlines() for log in logs: fo.write(log+'\n') fo.write('\n') finally: fo.close() #写回最后一行 def write_last_line(txtpath,line): fo = open(txtpath,'w+') try: fo.write(line) finally: fo.close() #遍历行 #多于两行则自动生成post review def enum_line(txtpath,logpath,repo): nlog('/mnt/rb/rb.log','Trying repositor '+repo+'\n') fi = open(txtpath) try: lines=fi.readlines() linesize=len(lines) if linesize <= 1: nlog('/mnt/rb/rb.log','Skiping repositor '+repo+'\n') return for i in range(0, linesize): if i+1<linesize: rbRepo = nsvnutils.get_repo_name(repo) if len(rbRepo)==0 : nlog('/mnt/rb/rb.log','Skiping repositor '+repo+'\n') return nlog('/mnt/rb/rb.log','Parsing repository '+rbRepo+'\n') create_rbt_command(rbRepo,lines[i].replace('\n','').replace('\r',''),lines[i+1].replace('\n','').replace('\r',''),logpath) except Exception as ex: nlog('/mnt/rb/rb.log',str(ex)) finally: fi.close() write_last_line(txtpath,lines[linesize-1]) #递归遍历文件 def enum_file(targetdir,sufix,logpath): for root, dirs, files in os.walk(targetdir, True): for fname in files: fsufix = os.path.splitext(fname)[1][1:] repo = os.path.splitext(fname)[0] if sufix == fsufix: txtpath = root+"/"+fname #txtpath = root+"\\"+fname enum_line(txtpath,logpath,repo) #start here nlog("/mnt/rb/rb.log", 'Starting job on '+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')+'\n') enum_file("/mnt/rb","txt", "/mnt/rb/rb.log") #enum_file("D:/MyProducts/Python/ReviewBoard/rb","txt", "D:/MyProducts/Python/ReviewBoard/rb/rb.log") nlog("/mnt/rb/rb.log", 'Ending job on '+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')+'\n')
nsvnutils.py
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2016-11-24 @author: Hansen 获取指定svn文件夹下,指定svn版本的注释 ''' import os import sys #切换路径,并获取repository名称 def get_repo_name(repo): mydict = {'REPO1':'REPO1','REPO2':'REPO2'} if not mydict.get(repo): return '' os.chdir('/home/neohope/repository/'+mydict.get(repo)) #os.chdir('D:/MyProducts/Python/ReviewBoard/repo/'+mydict(repo)) return mydict[repo] #获取指定svn版本的注释 def get_svn_log(revision): cmd = 'svn log -r '+revision logs = os.popen(cmd).readlines() #for log in logs: # print(log) if len(logs)>3: print(logs[3].replace('\r','').replace('\n','')) return logs[3].replace('\r','').replace('\n','') else: print('no svn comment') return 'no svn comment' #获取指定svn版本的提交者 def get_svn_commiter(revision): cmd = 'svn log -r '+revision logs = os.popen(cmd).readlines() if len(logs)>2: ss=logs[1].split('|') if len(ss)>2: print(ss[1].strip().replace('\r','').replace('\n','')) return ss[1].strip().replace('\r','').replace('\n','') else: #print('no svn commiter') return 'no svn commiter' else: #print('no svn commiter') return 'no svn commiter' #start here #get_svn_log('193') #get_svn_commiter('193')
3、建立定时任务,执行脚本
crontab -l #半小时运行一次 */30 * * * * /home/neohope/scripts/runme.py
比较麻烦的是,仍需要在Linux下面,先把SVN的repository检出才可以。
同时要注意,要做好SVN及ReviewBoard之间名称的映射。。。