From f86d78fdca3da2785f7134e6ab8467848803d8ea Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 21 Sep 2018 16:39:08 +0800 Subject: [PATCH] add publish.py --- gitlab/githelper.py | 5 +++-- gitlab/publish.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 gitlab/publish.py diff --git a/gitlab/githelper.py b/gitlab/githelper.py index 481ebd1..859ed54 100644 --- a/gitlab/githelper.py +++ b/gitlab/githelper.py @@ -18,8 +18,8 @@ for proj in projects: http_url_to_repo = proj['http_url_to_repo'] name = proj['name'] path = proj['namespace']['path'] - if path != 'publish' or not ('game1008' in name): - continue +# if path != 'publish' or not ('game1008' in name): +# continue if not os.path.exists('repository/%s' % path): os.mkdir('repository/%s' % (path)) if not os.path.exists('repository/%s/%s' % (path, name)): @@ -27,6 +27,7 @@ for proj in projects: os.system('cd repository/%s/%s && git pull' % (path, name)) os.system('cd repository/%s/%s && git submodule init' % (path, name)) os.system('cd repository/%s/%s && git submodule update' % (path, name)) + continue submodules = os.listdir('repository/%s/%s/third_party' % (path, name)) for module_name in submodules: os.system('cd repository/%s/%s/third_party/%s && git checkout master && git pull' % diff --git a/gitlab/publish.py b/gitlab/publish.py new file mode 100644 index 0000000..27135b7 --- /dev/null +++ b/gitlab/publish.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import os +import sys +import json +import urllib.parse +import urllib.request +from optparse import OptionParser + +def publish_project(project, tag): +# print(project_name, project_tag) + PUBLISH_URL = "http://10.10.3.16:5012/publisttest" + post_data = { + 'project' : project, + 'tag' : tag, + } + post_data = urllib.parse.urlencode(post_data).encode('ascii') + req = urllib.request.Request(PUBLISH_URL) + data = urllib.request.urlopen(req, post_data).readall() + print(data) + +parser = OptionParser(usage="%prog [options]") +parser.add_option("-p", + "--projects", + action = "store", + type = "string", + dest = "projects", + help = "publish projects") +(options, args) = parser.parse_args() +if options.projects: + for project in options.projects.split(','): + project_name, project_tag = project.split('@') + publish_project(project_name, project_tag)