Commit d632259c authored by Jan Kotanski's avatar Jan Kotanski
Browse files

New upstream version 0.2.0

parent 1f26dfac
......@@ -2,3 +2,5 @@ include LICENSE
include README.rst
include man/glclone.1
include man/glpull.1
include man/glfromsvn.1
include man/glupload.1
Metadata-Version: 1.1
Name: gitlabgroups
Version: 0.1.0
Version: 0.2.0
Summary: Nexus Data writer implemented as a Tango Server
Home-page: https://github.com/nexdatas/writer
Author: Jan Kotanski
......
Metadata-Version: 1.1
Name: gitlabgroups
Version: 0.1.0
Version: 0.2.0
Summary: Nexus Data writer implemented as a Tango Server
Home-page: https://github.com/nexdatas/writer
Author: Jan Kotanski
......
......@@ -2,11 +2,15 @@ LICENSE
MANIFEST.in
README.rst
glclone
glfromsvn
glpull
glupload
setup.py
gitlabgroups/__init__.py
gitlabgroups/glclone.py
gitlabgroups/glfromsvn.py
gitlabgroups/glpull.py
gitlabgroups/glupload.py
gitlabgroups.egg-info/PKG-INFO
gitlabgroups.egg-info/SOURCES.txt
gitlabgroups.egg-info/dependency_links.txt
......@@ -14,4 +18,6 @@ gitlabgroups.egg-info/not-zip-safe
gitlabgroups.egg-info/requires.txt
gitlabgroups.egg-info/top_level.txt
man/glclone.1
man/glpull.1
\ No newline at end of file
man/glfromsvn.1
man/glpull.1
man/glupload.1
\ No newline at end of file
......@@ -19,4 +19,4 @@
""" Gitlab group tools """
__version__ = "0.1.0"
__version__ = "0.2.0"
#!/usr/bin/env python
# This file is part of nexdatas - Tango Server for NeXus data writer
#
# Copyright (C) 2012-2018 DESY, Jan Kotanski <jkotan@mail.desy.de>
#
# nexdatas is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# nexdatas is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nexdatas. If not, see <http://www.gnu.org/licenses/>.
#
""" gitlab tools for converting an svn repoitory to a local git repository"""
import subprocess
import sys
import argparse
class GLFromSVN(object):
""" GitLab Create a local git repository from an svn repository"""
def __init__(self, options):
""" the main program function
:param options: parser options
:type options: :class:`argparse.Namespace`
"""
self.__trunk = options.trunk or "trunk"
self.__branches = options.branches or "branches"
self.__tags = options.tags or "tags"
self.__svnurl = options.svnurl or \
"https://svn.code.sf.net/p/tango-ds/code/"
self.__svndir = options.args[0] if len(options.args) > 0 else ""
self.__url = "%s/%s" % (self.__svnurl, self.__svndir) \
if self.__svndir else options.url
self.__localdir = options.localdir or self.__url.split("/")[-1]
self.__authors = options.authors or "./authors.txt"
self.__tagmessage = options.tagmessage or "migrate svn to git"
def run(self):
""" the main program function
"""
# fetch all subgroups
clonecmd = 'git svn clone %s %s -T %s -b %s -t %s ' \
'--authors-file=%s' % (
self.__url, self.__localdir, self.__trunk,
self.__branches, self.__tags, self.__authors)
tagcmd = 'cd %s;' \
' \git for-each-ref refs/remotes/origin/tags |' \
' cut -d / -f 5-|' \
' while read ref; ' \
' do git tag -a "$ref" -m"%s" ' \
' "refs/remotes/origin/tags/$ref" && '\
' echo "Add a new tag: $ref"; ' \
' done' % (self.__localdir, self.__tagmessage)
branchcmd = 'cd %s;' \
'git for-each-ref refs/remotes/origin | ' \
'grep -v trunk | grep -v tag | cut -d / -f 4-| ' \
'while read ref; ' \
'do git checkout origin/$ref -b $ref &&' \
' echo "Add a new branch: $ref"; '\
'done' % (self.__localdir)
commands = [clonecmd, tagcmd, branchcmd]
if self.__url:
for cmd in commands:
try:
print(cmd)
process = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
shell=True)
proc_stdout = process.communicate()[0].strip()
if hasattr(proc_stdout, "decode"):
print(proc_stdout.decode())
except Exception as e:
print("Error: %s" % (str(e)))
def main():
""" the main program function
"""
#: pipe arguments
pipe = ""
if not sys.stdin.isatty():
pp = sys.stdin.readlines()
#: system pipe
pipe = "".join(pp)
description = "Command-line tool create a local git repository" \
" from a given svn repository"
epilog = 'examples:\n' \
' glfromsvn DeviceClasses/CounterTimer/DGG2 \n\n' \
' - create a local git repository in "DGG2" directory ' \
'and fetch authors emails from "./authors.txt" \n\n' \
parser = argparse.ArgumentParser(
description=description, epilog=epilog,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'args', metavar='svndir', type=str, nargs='?',
help='svn group directory, '
'e.g. "DeviceClasses/CounterTimer/DGG2"')
parser.add_argument(
"-T", "--trunk",
help='trunk svn directory, default: trunk',
dest="trunk", default="trunk")
parser.add_argument(
"-b", "--branches",
help='branch svn directory, default: branches',
dest="branches", default="branches")
parser.add_argument(
"-t", "--tags",
help='tag svn directory, default: tags',
dest="tags", default="tags")
parser.add_argument(
"-s", "--svn-url",
help='root svn url, '
'default: "https://svn.code.sf.net/p/tango-ds/code/"',
dest="svnurl",
default="https://svn.code.sf.net/p/tango-ds/code/")
parser.add_argument(
"-u", "--url",
help='full svn url with svn project directory, '
'e.g.: "https://svn.code.sf.net/p/tango-ds/code/'
'DeviceClasses/CounterTimer/DGG2"',
dest="url",
default="")
parser.add_argument(
"-l", "--local-dir",
help='local git directory, e.g.: "DGG2"',
dest="localdir",
default="")
parser.add_argument(
"-a", "--authors",
help='file with authors, '
'default: "./authors.txt"',
dest="authors", default="./authors.txt")
parser.add_argument(
"-m", "--tag-message",
help='tag message, '
'default: "migrate svn to git"',
dest="tagmessage", default="")
try:
options = parser.parse_args()
except Exception as e:
sys.stderr.write("Error: %s\n" % str(e))
sys.stderr.flush()
parser.print_help()
print("")
sys.exit(255)
#: command-line and pipe arguments
parg = []
if hasattr(options, "args"):
parg = [options.args] if options.args else []
if pipe:
parg.append(pipe)
options.args = parg
if not options.args and not options.url:
parser.print_help()
print("")
sys.exit(255)
try:
command = GLFromSVN(options)
command.run()
except Exception as e:
sys.stderr.write("Error: glfromsvn interrupted with:")
sys.stderr.write(str(e))
sys.stderr.flush()
sys.exit(255)
if __name__ == "__main__":
main()
#!/usr/bin/env python
# This file is part of nexdatas - Tango Server for NeXus data writer
#
# Copyright (C) 2012-2018 DESY, Jan Kotanski <jkotan@mail.desy.de>
#
# nexdatas is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# nexdatas is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nexdatas. If not, see <http://www.gnu.org/licenses/>.
#
""" gitlab tools for uploading a local git repository to a remote gitlab"""
import subprocess
import sys
import argparse
class GLUpload(object):
""" GitLab upload a local git repository to a remote gitlab"""
def __init__(self, options):
""" the main program function
:param options: parser options
:type options: :class:`argparse.Namespace`
"""
self.__user = options.user
self.__giturl = options.giturl or \
"https://eosc-pan-git.desy.de/tango-ds/"
self.__gitdir = options.args[0] if len(options.args) > 0 else ""
self.__url = "%s/%s.git" % (self.__giturl, self.__gitdir) \
if self.__gitdir else options.url
self.__localdir = options.localdir or "."
def run(self):
""" the main program function
"""
addcmd = 'cd %s; git remote add gitlab %s' \
% (self.__localdir, self.__url)
pushcmd = 'cd %s; git push -u gitlab --all ; ' \
'git push -u gitlab --tags' \
% self.__localdir
if self.__user:
addcmd = addcmd.replace("://", "://%s@" % self.__user)
commands = [addcmd, pushcmd]
if self.__url:
for cmd in commands:
try:
print(cmd)
process = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
shell=True)
proc_stdout = process.communicate()[0].strip()
if hasattr(proc_stdout, "decode"):
print(proc_stdout.decode())
except Exception as e:
print("Error: %s" % (str(e)))
def main():
""" the main program function
"""
#: pipe arguments
pipe = ""
if not sys.stdin.isatty():
pp = sys.stdin.readlines()
#: system pipe
pipe = "".join(pp)
description = "Command-line tool to upload a local git repository" \
" to a remote git repository"
epilog = 'examples:\n' \
' glupload DeviceClasses/CounterTimer/DGG2 \n\n' \
' - upload a local git repository in the "." directory ' \
'to https://eosc-pan-git.desy.de/tango-ds/DeviceClasses/' \
'CounterTimer/DGG2.git \n\n' \
parser = argparse.ArgumentParser(
description=description, epilog=epilog,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'args', metavar='group', type=str, nargs='?',
help='gitlab group, '
'e.g. "DeviceClasses/CounterTimer/DGG2"')
parser.add_argument(
"-g", "--git-url",
help='root git url, '
'default: "https://eosc-pan-git.desy.de/tango-ds/"',
dest="giturl",
default="https://eosc-pan-git.desy.de/tango-ds/")
parser.add_argument(
"-f", "--url",
help='full git url with git subgroups and a project name, '
'e.g.: "https://eosc-pan-git.desy.de/tango-ds/'
'deviceclasses/countertimer/gdd2"',
dest="url",
default="")
parser.add_argument(
"-u", "--user",
help="gitlab user",
dest="user", default="")
parser.add_argument(
"-l", "--local-dir",
help='local git directory, e.g.: "DGG2"',
dest="localdir",
default=".")
try:
options = parser.parse_args()
except Exception as e:
sys.stderr.write("Error: %s\n" % str(e))
sys.stderr.flush()
parser.print_help()
print("")
sys.exit(255)
#: command-line and pipe arguments
parg = []
if hasattr(options, "args"):
parg = [options.args] if options.args else []
if pipe:
parg.append(pipe)
options.args = parg
if not options.args and not options.url:
parser.print_help()
print("")
sys.exit(255)
try:
command = GLUpload(options)
command.run()
except Exception as e:
sys.stderr.write("Error: glupload interrupted with:")
sys.stderr.write(str(e))
sys.stderr.flush()
sys.exit(255)
if __name__ == "__main__":
main()
#!/usr/bin/env python3
from gitlabgroups import glfromsvn
glfromsvn.main()
#!/usr/bin/env python3
from gitlabgroups import glupload
glupload.main()
usage: glfromsvn [-h] [-T TRUNK] [-b BRANCHES] [-t TAGS] [-s SVNURL] [-u URL]
[-l LOCALDIR] [-a AUTHORS] [-m TAGMESSAGE]
[svndir]
Command-line tool
positional arguments:
svndir
optional arguments:
-h, --help show this help message and exit
.TH gifromsvn 1 "2020-05-13" gifromsvn
.SH NAME
.B gifromsvn
\- command-line tool to create a local git repository from a given svn repository
.SH SYNOPSIS
.B gifromsvn
.I [-h] [-T TRUNK] [-b BRANCHES] [-t TAGS] [-s SVNURL] [-u URL] [-l LOCALDIR] [-a AUTHORS] [-m TAGMESSAGE] [svndir]
.SH OPTIONS
.IP "svndir"
svn group directory, e.g. "DeviceClasses/CounterTimer/DGG2"
optional arguments:
.IP "-h, --help"
show this help message and exit
.IP "-T TRUNK, --trunk TRUNK"
trunk svn directory, default: trunk
.IP "-b BRANCHES, --branches BRANCHES"
branch svn directory, default: branches
.IP "-t TAGS, --tags TAGS"
tag svn directory, default: tags
.IP "-s SVNURL, --svn-url SVNURL"
root svn url, default: "https://svn.code.sf.net/p/tango-ds/code/"
.IP "-u URL, --url URL"
full svn url with svn project directory, e.g.: "https://svn.code.sf.net/p/tango-ds/code/DeviceClasses/CounterTimer/DGG2"
.IP "-l LOCALDIR, --local-dir LOCALDIR"
local git directory, e.g.: "DGG2"
.IP "-a AUTHORS, --authors AUTHORS"
file with authors, default: "./authors.txt"
.IP "-m TAGMESSAGE, --tag-message TAGMESSAGE"
tag message, default: "migrate svn to git"
.SH EXAMPLES:
glfromsvn DeviceClasses/CounterTimer/DGG2
- create a local git repository in "DGG2" directory and fetch authors email
.SH SEE ALSO
https://github.com/jkotan/nexdatas/
.SH COPYRIGHT
Copyrights (c) 2020, GNU GPL v2, DESY, Jan Kotanski
.SH BUGS
Please report bugs on the project's mailing list:
mailto://jankotan@gmail.com
.SH AUTHORS
Jan Kotanski <jankotan@gmail.com>
.TH glupload 1 "2020-05-13" glupload
.SH NAME
.B glupload
\- command-line tool to upload a local git repository to a remote git repository
.SH SYNOPSIS
.B glupload
.I [-h] [-g GITURL] [-u URL] [-l LOCALDIR] [group]
.SH OPTIONS
.IP "group"
gitlab group, e.g. "DeviceClasses/CounterTimer/DGG2"
optional arguments:
.IP "-h, --help"
show this help message and exit
.IP "-g GRPURL, --groupurl GRPURL"
root git url, default: "https://eosc-pan-git.desy.de/tango-ds/"
.IP "-u URL, --url URL"
full git url with git subgroups and a project name, e.g.: "https://eosc-pan-git.desy.de/tango-ds/deviceclasses/countertimer/gdd2"
.IP "-u USER, --user USER"
gitlab user
.IP "-l LOCALDIR, --local-dir LOCALDIR"
local git directory, e.g.: "DGG2"
.SH EXAMPLES:
glupload DeviceClasses/CounterTimer/DGG2
- upload a local git repository in the "." directory to https://eosc-pan-git.desy.de/tango-ds/DeviceClasses/CounterTimer/DGG2.git
.SH SEE ALSO
https://github.com/jkotan/nexdatas/
.SH COPYRIGHT
Copyrights (c) 2020, GNU GPL v2, DESY, Jan Kotanski
.SH BUGS
Please report bugs on the project's mailing list:
mailto://jankotan@gmail.com
.SH AUTHORS
Jan Kotanski <jankotan@gmail.com>
......@@ -115,7 +115,7 @@ SETUPDATA = dict(
'Programming Language :: Python :: 3.7',
],
install_requires=install_requires,
scripts=['glclone', 'glpull'],
scripts=['glclone', 'glpull', 'glfromsvn', 'glupload'],
cmdclass={
# 'test': TestCommand,
'build_sphinx': BuildDoc
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment