From 45934b7b625e85243da1200c39c71093214ce2af Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Tue, 16 Oct 2012 17:19:37 +0100 Subject: [PATCH] Initial hpgit python project Initial files for the hpgit python project Change-Id: Iebd1f5aa789dcd9574a00bb8837e4596bf55fa88 JIRA: CICD-242 --- README | 14 ++++++------- ghp/__init__.py | 0 ghp/version.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ git-hp | 17 ++++++++++++++++ setup.py | 44 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 ghp/__init__.py create mode 100644 ghp/version.py create mode 100755 git-hp create mode 100644 setup.py diff --git a/README b/README index 2b22080..2461aef 100644 --- a/README +++ b/README @@ -1,8 +1,8 @@ -hpgit is a Python application providing a default workflow for HP Cloud -projects (i.e. feature branch creation/finishing, release starting/finishing) -on top of git. The operations are performed using Git commands. +hpgit is a Python application providing commands to support usage of git for +HP Cloud projects (i.e. feature branch creation/finishing, release +starting/finishing). The operations are performed using Git commands. -hpgit can use multiple configuration files to specify project, team and -individual preferences when working on projects. This allows for a number of -similar but slightly different workflows to be implemented, while being -described by the same commands. +hpgit is intended to make use of multiple configuration files to specify +project, team and individual preferences. This allows for variations in similar +workflows to be supported, without needing developers from different projects +to be aware of the specific operations need for other projects. diff --git a/ghp/__init__.py b/ghp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ghp/version.py b/ghp/version.py new file mode 100644 index 0000000..84b5333 --- /dev/null +++ b/ghp/version.py @@ -0,0 +1,52 @@ +# +# Copyright (c) 2012 Hewlett-Packard +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import datetime +import os +import shlex +import subprocess + +def run_command(cmd, status=False, env={}): + if VERBOSE: + print(datetime.datetime.now(), "Running:", cmd) + cmd_list = shlex.split(str(cmd)) + newenv = os.environ + newenv.update(env) + p = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, env=newenv) + (out, nothing) = p.communicate() + out = out.decode('utf-8') + if status: + return (p.returncode, out.strip()) + return out.strip() + +def git_describe_version(): + try: + v = run_command('git describe --tags --dirty') + except RuntimeException, e: + pass + + return v + +def get_version(): + try: + return git_describe_version() + except: + pass + + return 'unknown-version' + +version = get_version() diff --git a/git-hp b/git-hp new file mode 100755 index 0000000..8be7b3f --- /dev/null +++ b/git-hp @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# +# Copyright (c) 2012 Hewlett-Packard +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..829219d --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# +# Copyright (c) 2012 Hewlett-Packard +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import os +from setuptools import setup, find_packages +from ghp import version + +# taken from setuptools example. +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + +setup( + name = "hpgit", + version = version.version, + author = "Darragh Bailey", + author_email = "dbailey@hp.com", + description = ("Tool supporting HPCloud git workflows."), + license = "Apache License (2.0)", + keywords = "git hpcloud workflow", + url = "https://wiki.hpcloud.net/display/auto/hpgit", + scripts = ['git-hp'], + packages = find_packages(exclude=['test']), + long_description=read('README'), + classifiers=[ + "Development Status :: 2 - Pre-Alpha", + "Topic :: Utilities", + "License :: OSI Approved :: Apache License", + ], +)