Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable use inside a virtualenv #1

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
@@ -1,3 +1,6 @@
.*.swp
*~
repo_refs.yaml.variables
.Python
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing this ignore?

bin/
include/
lib/
51 changes: 27 additions & 24 deletions README.md
@@ -1,49 +1,52 @@
This repository contains scripts for managing multiple outstanding patches to
TripleO (or other gerrit based projects).
This repository contains scripts for managing multiple outstanding patches
to a gerrit based project. It was initially developed for managing TripleO
deployments, and still makes certain TripleOish assumptions (patches welcome
if you find the tool more generally useful)

The source repo includes:

- tooling to combine arbitrary unmerged gerrit patches (prep_source_repos)
which will also export an rc file with git refs based on the combined
branches
- a sample config file that we're using (repo_refs.yaml)
- some example inputs for doing rack testing of tripleo in the rack-testing
subdir
- a sample config file that we're using for our TripleO deployments
(repo_refs.yaml)

## Usage

* create a repo_refs.yaml in your TRIPLEO_ROOT (see the one in the root of this
repository for inspiration).
* create a repo_refs.yaml (see the one in the root of this repository
for inspiration).

* add the tripleo-end-to-end bin directory to your path (or symlink the
specific scripts into place, or $up to you).
* run prep_source_repos $YOUR\_REFS\_FILE $DESTINATIION\_DIR to checkout and
update the repositories specified by the refs file (in a TripleO context,
$DESTINATION\_DIR will usually be "$TRIPLEO\_ROOT").

* run prep_source_repos $YOUR\_REFS\_FILE $TRIPLEO\_ROOT to checkout and update
the repositories specified by the refs file. Note that local edits are saved
via git stash whenever you refresh your source repos, and restored after the
update (which may, of course, fail). This provides a convenient way to use
local edits / work in progress for repositories that are used directly (vs
e.g. those that are cloned into images).
Note that local edits are saved via git stash whenever you refresh your
source repos, and restored after the update (which may, of course,
fail). This provides a convenient way to use local edits / work in
progress for repositories that are used directly (vs e.g. those that are
cloned into images).

* source YOUR_REFS_FILE.variables to configure TripleO scripts to use your
freshly integrated branches
* (optional) source YOUR_REFS_FILE.variables to configure TripleO scripts to
use your freshly integrated branches

* proceed with any tripleo activies you might have (building images, deploying,
etc etc).

## Advanced use

Refs that don't match the xx/yy/zz form of gerrit refs are presumed to be local
work-in-progress branches. These are not fetched, but are merged into the
rollup branch along with all the other patches. With a little care this permits
working effectively with multiple patchsets in one project without them being
made into a stack in gerrit.
Refs that don't match the xx/yy/zz form of gerrit refs are presumed to be
local work-in-progress branches. These are not fetched, but are merged into
the rollup branch along with all the other patches. With a little care this
permits working effectively with multiple patchsets in one project without
them being made into a stack in gerrit.

Refs of the form xx/yy/0 are late-bound references to gerrit - they will use
the gerrit REST API to find out the latest version and will use that.

When running prep-source-repos any additional arguments after the refs and
output dir are used to filter the repositories to fetch - so when working on
(say) two local orthogonal patches to nova, and you need to update your rollup
branch just do::
(say) two local orthogonal patches to nova, and you need to update your
rollup branch just do::

prep-source-repos foo bar nova

Expand Down
Empty file added prep_source_repos/__init__.py
Empty file.
31 changes: 27 additions & 4 deletions bin/prep_source_repos → prep_source_repos/cmd.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

import argparse
import json
Expand Down Expand Up @@ -40,9 +40,17 @@ def make_repos(thing, path_stack):

def main():
parser = argparse.ArgumentParser()
parser.add_argument("--clean", help="If set, reset each repo to upstream "
"state with no patches applied (ignoring refs in "
"config file)", action='store_true')
parser.add_argument("refs", help="the yaml config file")
parser.add_argument("output", help="where to put the downloaded repositories")
parser.add_argument("repos", help="what repos to update", nargs="*")
parser.add_argument("--reference", "-r", help="If set, any git clone "
"operations will look for a local repository to set "
"as a reference, to save downloading again."
"Use this multiple times to set mutiple paths to "
"hunt for local references", action="append")
args = parser.parse_args()
SRC_ROOT = os.path.abspath(args.output)
with open(args.refs, 'rt') as arg_file:
Expand All @@ -58,14 +66,29 @@ def main():
resolved_refs = {}

for repo, (remote, gerrit) in CONF['repos'].items():
print repo, remote, gerrit
pass
if args.repos and repo not in args.repos:
continue
rd = os.path.join(SRC_ROOT, repo)

if not os.path.isdir(os.path.join(rd)):
check_call(['git', 'clone', remote, rd])

refs = CONF['gerrit_refs'].get(repo, ())
clone_args = ['git', 'clone']
if args.reference:
for dir in args.reference:
reference_dir = os.path.join(dir, repo)
print "Checking %s" % reference_dir
if os.path.isdir(reference_dir):
clone_args += ['--reference', reference_dir]
continue
clone_args += [remote, rd]
print "CLONING: %s" % clone_args
check_call(clone_args)

if args.clean:
refs = []
else:
refs = CONF['gerrit_refs'].get(repo, ())

git_refs = ['+master:review/master']
for ref in refs:
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
@@ -0,0 +1,2 @@
PyYAML>=3.11
requests>=2.4.0
24 changes: 24 additions & 0 deletions setup.cfg
@@ -0,0 +1,24 @@
[metadata]
name = prep_source_repos
author = OpenStack Foundation
author-email = openstack-dev@lists.openstack.org
summary = Tool to manage a local checkout of a set of unlanded patches on a Gerrit repository
description-file = README.md
license = Apache-2
classifier =
Development Status :: 4 - Beta
Environment :: Console
Environment :: OpenStack
Intended Audience :: Developers
Intended Audience :: Information Technology
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
keywords =
gerrit
[files]
packages =
prep_source_repos
[entry_points]
console_scripts =
prep_source_repos = prep_source_repos.cmd:main
8 changes: 8 additions & 0 deletions setup.py
@@ -0,0 +1,8 @@
#!/usr/bin/env python

from setuptools import setup

setup(
setup_requires=['pbr'],
pbr=True,
)