From 127c23717c52871b360f8900198920e919126499 Mon Sep 17 00:00:00 2001 From: Tuschl Date: Wed, 12 Aug 2020 11:48:00 +0200 Subject: [PATCH 1/3] Add .gitignore --- .gitignore | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab76353 --- /dev/null +++ b/.gitignore @@ -0,0 +1,230 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/python,vim,linux,macos,windows +# Edit at https://www.toptal.com/developers/gitignore?templates=python,vim,linux,macos,windows + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/python,vim,linux,macos,windows From 61e125f11e6d9fae82822a74e751d508add6ddb5 Mon Sep 17 00:00:00 2001 From: Tuschl Date: Wed, 12 Aug 2020 12:10:15 +0200 Subject: [PATCH 2/3] Add support using Gitlab's numerical project ID --- gitlab-manager | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitlab-manager b/gitlab-manager index 4e56e8f..95a06a3 100755 --- a/gitlab-manager +++ b/gitlab-manager @@ -126,7 +126,10 @@ if __name__ == '__main__': print(e) exit() try: - projects = gl.projects.list(search=args.project) + if args.project.isdecimal(): + projects = [gl.projects.get(args.project)] + else: + projects = gl.projects.list(search=args.project) except exceptions.MissingSchema: log.error("Error with the URL defined") exit() From b1363ab1843878b32bc00609a87170254e469264 Mon Sep 17 00:00:00 2001 From: Tuschl Date: Wed, 12 Aug 2020 12:56:59 +0200 Subject: [PATCH 3/3] Add argument to control MR state for listing Previously the `mr ls` action would only list opened MRs. To give more flexibility, this commit adds an optional argument for specifying the state that should be listed (including *any*). Valid argument values are taken directly from Gitlab's API docs and are thus directly passed. The argument defaults to `opened`, so the default behavior remains unchanged. --- gitlab-manager | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gitlab-manager b/gitlab-manager index 95a06a3..1e3c76b 100755 --- a/gitlab-manager +++ b/gitlab-manager @@ -19,9 +19,9 @@ class MergeRequest: def print_mr(self): return "### {}: {}\n\n{}\n\n * by: {}\n\n * Merge Request ID:{}\n".format(self.Label, self.Title, self.Description, self.Author, self.Id) -def list_mrs(project, wip): +def list_mrs(project, state, wip): print("\nHere is the list of MRs for your chosen project:\n") - mrs = project.mergerequests.list(state='opened', order_by='updated_at', wip=wip) + mrs = project.mergerequests.list(state=state, order_by='updated_at', wip=wip) all_mr = "" for mr in mrs: current = MergeRequest(mr) @@ -82,6 +82,10 @@ def init_argparse(): ls_mr = subparsers.add_parser('ls') ls_mr.add_argument("--wip", dest='wip', action='store', type=str, help='search wip or not', choices=['yes', 'no']) + ls_mr.add_argument("--state", dest='state', action='store', type=str, + help='filter for the specified state', + choices=['all', 'opened', 'closed', 'locked', 'merged'], + default='opened') update_mr = subparsers.add_parser('update') update_mr.add_argument('mr_id') update_mr.add_argument("--label", dest='label', action='store', type=str, @@ -142,7 +146,7 @@ if __name__ == '__main__': project = projects[0] if args.command == "mr": if args.action == "ls": - list_mrs(project, args.wip) + list_mrs(project, args.state, args.wip) if args.action == "update": update_mr(project, args.mr_id, args.label, args.tag) if args.command == "changelog":