Skip to content

Commit

Permalink
substitute /releng for /.tito #161
Browse files Browse the repository at this point in the history
if /releng is present it will be used. Otherwise /.tito will be used.
  • Loading branch information
xsuchy committed Apr 26, 2015
1 parent 4091af9 commit 5beaf7a
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 59 deletions.
12 changes: 6 additions & 6 deletions README.mkd
Expand Up @@ -52,7 +52,7 @@ From your git repository:

tito init

This will create a top-level metadata directory called "rel-eng/" and commit it
This will create a top-level metadata directory called ".tito/" and commit it
to git. This directory will store tito's configuration and package metadata on
a per branch basis. It will be filtered out when creating .tar.gz's.

Expand All @@ -70,15 +70,15 @@ root of the project at the top level of the git repository:
docs/
mypackage.spec
README
rel-eng/
.tito/
src/
test/

For a multi-project git repository, packages can be defined in various
sub-directories, provided they do not nest (i.e. walking up the tree, two spec
files will never be encountered):

rel-eng/
.tito/
package1/
docs/
mypackage.spec
Expand Down Expand Up @@ -113,7 +113,7 @@ By default if you omit --keep-version, tito will tag by bumping the rpm
version. (i.e. we bump the Z in X.Y.Z. If you'd prefer to bump the package
release instead (normally should just be used for changes to the spec file or
patches applied within it), you can change the 'tagger' class in
rel-eng/tito.props to ReleaseTagger. This will affect all packages in this git
.tito/tito.props to ReleaseTagger. This will affect all packages in this git
branch, if you'd prefer to do this on a per-package basis you can do so in a
package specific tito.props. (see section below)

Expand Down Expand Up @@ -154,7 +154,7 @@ RELEASING PACKAGES

Tito supports a mechanism where you can define multiple release targets.

In rel-eng/releasers.conf, create a section like:
In .tito/releasers.conf, create a section like:

[yum-f15-x86_64]
releaser = tito.release.YumRepoReleaser
Expand Down Expand Up @@ -207,7 +207,7 @@ history, and run:
git reset --hard HEAD^1

If your project is standalone (no remote reference you communicate with as
authoritative) you may wish to set offline = "true" in rel-eng/tito.props under
authoritative) you may wish to set offline = "true" in .tito/tito.props under
the globalconfig section, so you do not need to specify --offline with each
invocation.

Expand Down
6 changes: 3 additions & 3 deletions doc/builders.mkd
Expand Up @@ -6,7 +6,7 @@ An unorthodox builder which can build packages for a git repo which does not act

One strategy is currently included which parses a CLI argument to the build command which points to the source to use.

Configuration for FetchBuilder in rel-eng/tito.props would look like:
Configuration for FetchBuilder in .tito/tito.props would look like:

[buildconfig]
builder = tito.builder.FetchBuilder
Expand All @@ -18,7 +18,7 @@ Once configured a build can be run with:

**tito build --rpm --arg=source=/home/username/extsrc-0.0.1.tar.gz**

Note that this does not require a tito tag to have been run, and technically the rel-eng/tito.props does not have to be committed to the git repo. This builder can be used on a repository you do not control or do not wish to push tito configuration into.
Note that this does not require a tito tag to have been run, and technically the .tito/tito.props does not have to be committed to the git repo. This builder can be used on a repository you do not control or do not wish to push tito configuration into.

The ArgSourceStrategy has a simple mechanism where it will try to parse the version and release to build from the filename with a regular expression. If you need something more advanced, you can override any or all of this behaviour by implementing a custom strategy for the fetch builder. (see lib_dir in **man 5 tito.props**)

Expand All @@ -41,7 +41,7 @@ Add the spec file as normal, but add the tarball/source via git-annex instead:
git annex add tito-0.4.18.tar.gz
git commit -m "add tito 0.4.18"

Edit rel-eng/tito.props to change the builder to the GitAnnexBuilder:
Edit .tito/tito.props to change the builder to the GitAnnexBuilder:

[globalconfig]
default_builder = tito.builder.GitAnnexBuilder
Expand Down
4 changes: 2 additions & 2 deletions rel-eng/tito.props
@@ -1,12 +1,12 @@
[globalconfig]
default_builder = tito.builder.Builder
default_tagger = tito.tagger.VersionTagger
lib_dir = rel-eng/custom/
lib_dir = .tito/custom/

[buildconfig]
builder = tito.builder.Builder
tagger = tito.tagger.VersionTagger
lib_dir = rel-eng/custom/
lib_dir = .tito/custom/

[tag1]
disttag = el5
Expand Down
4 changes: 2 additions & 2 deletions src/tito/builder/main.py
Expand Up @@ -358,7 +358,7 @@ def __init__(self, name=None, tag=None, build_dir=None,
self.relative_project_dir = get_relative_project_dir(
project_name=self.project_name, commit=self.git_commit_id)
if self.relative_project_dir is None and self.test:
sys.stderr.write("WARNING: rel-eng/packages/%s doesn't exist "
sys.stderr.write("WARNING: .tito/packages/%s doesn't exist "
"in git, using current directory\n" % self.project_name)
self.relative_project_dir = get_relative_project_dir_cwd(
self.git_root)
Expand Down Expand Up @@ -510,7 +510,7 @@ def _get_display_version(self):
"""
Get the package display version to build.
Normally this is whatever is rel-eng/packages/. In the case of a --test
Normally this is whatever is .tito/packages/. In the case of a --test
build it will be the SHA1 for the HEAD commit of the current git
branch.
"""
Expand Down
20 changes: 10 additions & 10 deletions src/tito/cli.py
Expand Up @@ -22,8 +22,8 @@

from tito.common import find_git_root, error_out, debug, get_class_by_name, \
BUILDCONFIG_SECTION, DEFAULT_BUILDER, BUILDCONFIG_SECTION, DEFAULT_TAGGER, \
create_builder, find_git_root, get_project_name, get_relative_project_dir, \
DEFAULT_BUILD_DIR, run_command
create_builder, get_project_name, get_relative_project_dir, \
DEFAULT_BUILD_DIR, run_command, tito_config_dir
from tito.compat import RawConfigParser, getstatusoutput, getoutput
from tito.exception import TitoException

Expand Down Expand Up @@ -77,14 +77,14 @@ def load(self):

def _read_config(self):
"""
Read global build.py configuration from the rel-eng dir of the git
Read global build.py configuration from the .tito dir of the git
repository we're being run from.
NOTE: We always load the latest config file, not tito.props as it
was for the tag being operated on.
"""
# List of filepaths to config files we'll be loading:
rel_eng_dir = os.path.join(find_git_root(), "rel-eng")
rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
filename = os.path.join(rel_eng_dir, TITO_PROPS)
if not os.path.exists(filename):
error_out("Unable to locate branch configuration: %s"
Expand Down Expand Up @@ -491,9 +491,9 @@ def _validate_options(self):

def _read_releaser_config(self):
"""
Read the releaser targets from rel-eng/releasers.conf.
Read the releaser targets from .tito/releasers.conf.
"""
rel_eng_dir = os.path.join(find_git_root(), "rel-eng")
rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
filename = os.path.join(rel_eng_dir, RELEASERS_CONF_FILENAME)
config = RawConfigParser()
config.read(filename)
Expand Down Expand Up @@ -701,7 +701,7 @@ def main(self, argv):
# calling main will result in a configuration error.
should_commit = False

rel_eng_dir = os.path.join(find_git_root(), "rel-eng")
rel_eng_dir = os.path.join(find_git_root(), '.tito')
print("Creating tito metadata in: %s" % rel_eng_dir)

propsfile = os.path.join(rel_eng_dir, TITO_PROPS)
Expand Down Expand Up @@ -736,7 +736,7 @@ def main(self, argv):
# write out readme file explaining what pkg_dir is for
readme = os.path.join(pkg_dir, '.readme')
out_f = open(readme, 'w')
out_f.write("the rel-eng/packages directory contains metadata files\n")
out_f.write("the .tito/packages directory contains metadata files\n")
out_f.write("named after their packages. Each file has the latest tagged\n")
out_f.write("version and the project's relative directory.\n")
out_f.close()
Expand Down Expand Up @@ -795,7 +795,7 @@ def _run_untagged_commits(self, config):
print("Scanning for packages that may need to be tagged...")
print("")
git_root = find_git_root()
rel_eng_dir = os.path.join(git_root, "rel-eng")
rel_eng_dir = os.path.join(git_root, tito_config_dir())
os.chdir(git_root)
package_metadata_dir = os.path.join(rel_eng_dir, "packages")
for root, dirs, files in os.walk(package_metadata_dir):
Expand All @@ -821,7 +821,7 @@ def _run_untagged_report(self, config):
print("Scanning for packages that may need to be tagged...")
print("")
git_root = find_git_root()
rel_eng_dir = os.path.join(git_root, "rel-eng")
rel_eng_dir = os.path.join(git_root, tito_config_dir())
os.chdir(git_root)
package_metadata_dir = os.path.join(rel_eng_dir, "packages")
for root, dirs, files in os.walk(package_metadata_dir):
Expand Down
24 changes: 19 additions & 5 deletions src/tito/common.py
Expand Up @@ -280,6 +280,15 @@ def find_git_root():
cdup = "./"
return os.path.abspath(cdup)

def tito_config_dir():
""" Returns "rel-eng" for old tito projects and ".tito" for
recent projects.
"""
tito_dir = os.path.join(find_git_root(), ".tito")
if os.path.isdir(tito_dir):
return ".tito"
else:
return "rel-eng"

def extract_sha1(output):
match = SHA_RE.search(output)
Expand Down Expand Up @@ -533,11 +542,16 @@ def get_relative_project_dir(project_name, commit):
This could be a different directory than where the project currently
resides, so we export a copy of the project's metadata from
rel-eng/packages/ at the point in time of the tag we are building.
.tito/packages/ at the point in time of the tag we are building.
"""
cmd = "git show %s:rel-eng/packages/%s" % (commit,
cmd = "git show %s:%s/packages/%s" % (commit, tito_config_dir(),
project_name)
try:
(status, pkg_metadata) = getstatusoutput(cmd)
except:
cmd = "git show %s:%s/packages/%s" % (commit, "rel-eng",
project_name)
(status, pkg_metadata) = getstatusoutput(cmd)
(status, pkg_metadata) = getstatusoutput(cmd)
tokens = pkg_metadata.strip().split(" ")
debug("Got package metadata: %s" % tokens)
if status != 0:
Expand Down Expand Up @@ -666,12 +680,12 @@ def get_git_repo_url():
def get_latest_tagged_version(package_name):
"""
Return the latest git tag for this package in the current branch.
Uses the info in rel-eng/packages/package-name.
Uses the info in .tito/packages/package-name.
Returns None if file does not exist.
"""
git_root = find_git_root()
rel_eng_dir = os.path.join(git_root, "rel-eng")
rel_eng_dir = os.path.join(git_root, tito_config_dir())
file_path = "%s/packages/%s" % (rel_eng_dir, package_name)
debug("Getting latest package info from: %s" % file_path)
if not os.path.exists(file_path):
Expand Down
4 changes: 2 additions & 2 deletions src/tito/config_object.py
Expand Up @@ -15,7 +15,7 @@
"""

import os
from tito.common import find_git_root
from tito.common import find_git_root, tito_config_dir


class ConfigObject(object):
Expand All @@ -38,4 +38,4 @@ def __init__(self, config=None):
config.get(section, options))

self.git_root = find_git_root()
self.rel_eng_dir = os.path.join(self.git_root, "rel-eng")
self.rel_eng_dir = os.path.join(self.git_root, tito_config_dir())
10 changes: 5 additions & 5 deletions src/tito/tagger/main.py
Expand Up @@ -413,7 +413,7 @@ def release_type(self):

def _update_package_metadata(self, new_version):
"""
We track package metadata in the rel-eng/packages/ directory. Each
We track package metadata in the .tito/packages/ directory. Each
file here stores the latest package version (for the git branch you
are on) as well as the relative path to the project's code. (from the
git root)
Expand Down Expand Up @@ -462,12 +462,12 @@ def _check_tag_does_not_exist(self, new_tag):

def _clear_package_metadata(self):
"""
Remove all rel-eng/packages/ files that have a relative path
Remove all .tito/packages/ files that have a relative path
matching the package we're tagging a new version of. Normally
this just removes the previous package file but if we were
renaming oldpackage to newpackage, this would git rm
rel-eng/packages/oldpackage and add
rel-eng/packages/spacewalk-newpackage.
.tito/packages/oldpackage and add
.tito/packages/spacewalk-newpackage.
"""
metadata_dir = os.path.join(self.rel_eng_dir, "packages")
for filename in os.listdir(metadata_dir):
Expand Down Expand Up @@ -546,7 +546,7 @@ def _version_file_template(self):
provide a configuration in tito.props to a file that is a
python string.Template conforming blob, like
[version_template]
template_file = ./rel-eng/templates/my_java_properties
template_file = ./.tito/templates/my_java_properties
variables defined inside the template are $version and $release
Expand Down
6 changes: 3 additions & 3 deletions test/functional/fetch_tests.py
Expand Up @@ -22,7 +22,7 @@

from os.path import join

from tito.common import run_command
from tito.common import run_command, tito_config_dir
from tito.compat import *
from functional.fixture import TitoGitTestFixture, tito

Expand Down Expand Up @@ -72,7 +72,7 @@ def tearDown(self):
def test_simple_build_no_tag(self):
# We have not tagged here. Build --rpm should just work:
self.assertFalse(os.path.exists(
join(self.pkg_dir, 'rel-eng/packages/extsrc')))
join(self.pkg_dir, '.tito/packages/extsrc'))

tito('build --rpm --output=%s --no-cleanup --debug --arg=source=%s ' %
(self.output_dir, self.source_filename))
Expand All @@ -87,7 +87,7 @@ def test_tag_rejected(self):
(self.output_dir, self.source_filename))

def _setup_fetchbuilder_releaser(self, yum_repo_dir):
self.write_file(join(self.repo_dir, 'rel-eng/releasers.conf'),
self.write_file(join(self.repo_dir, '.tito/releasers.conf'),
RELEASER_CONF % yum_repo_dir)

def test_with_releaser(self):
Expand Down
4 changes: 2 additions & 2 deletions test/functional/fixture.py
Expand Up @@ -122,8 +122,8 @@ def setUp(self):

# Next we tito init:
tito("init")
run_command('echo "offline = true" >> rel-eng/tito.props')
run_command('git add rel-eng/tito.props')
run_command('echo "offline = true" >> .tito/tito.props')
run_command('git add .tito/tito.props')
run_command("git commit -m 'set offline in tito.props'")

def tearDown(self):
Expand Down
8 changes: 4 additions & 4 deletions test/functional/multiproject_tests.py
Expand Up @@ -48,7 +48,7 @@ def release_bumped(initial_version, new_version):
[version_template]
destination_file = version.txt
template_file = rel-eng/templates/version.rb
template_file = .tito/templates/version.rb
"""

VERSION_TEMPLATE_FILE = """
Expand Down Expand Up @@ -90,9 +90,9 @@ def test_template_version_tagger(self):
pkg_dir = join(self.repo_dir, 'pkg3')
filename = join(pkg_dir, "tito.props")
self.write_file(filename, TEMPLATE_TAGGER_TITO_PROPS)
run_command('mkdir -p %s' % join(self.repo_dir, 'rel-eng/templates'))
run_command('mkdir -p %s' % join(self.repo_dir, '.tito/templates'))
self.write_file(join(self.repo_dir,
'rel-eng/templates/version.rb'), VERSION_TEMPLATE_FILE)
'.tito/templates/version.rb'), VERSION_TEMPLATE_FILE)

os.chdir(self.repo_dir)
run_command('git add pkg3/tito.props')
Expand All @@ -119,7 +119,7 @@ def test_initial_tag_keep_version(self):
for pkg_name in TEST_PKGS:
self.assertTrue(tag_exists_locally("%s-0.0.1-1" % pkg_name))
self.assertTrue(os.path.exists(os.path.join(self.repo_dir,
"rel-eng/packages", pkg_name)))
".tito/packages", pkg_name)))

def test_release_tagger(self):
os.chdir(os.path.join(self.repo_dir, 'pkg2'))
Expand Down
2 changes: 1 addition & 1 deletion test/functional/release_yum_tests.py
Expand Up @@ -60,7 +60,7 @@ def tearDown(self):
pass

def _setup_fetchbuilder_releaser(self, yum_repo_dir):
self.write_file(join(self.repo_dir, 'rel-eng/releasers.conf'),
self.write_file(join(self.repo_dir, '.tito/releasers.conf'),
RELEASER_CONF % yum_repo_dir)

def test_with_releaser(self):
Expand Down
6 changes: 3 additions & 3 deletions test/functional/singleproject_tests.py
Expand Up @@ -44,10 +44,10 @@ def setUp(self):
def test_init_worked(self):
# Not actually running init here, just making sure it worked when
# run during setup.
self.assertTrue(os.path.exists(os.path.join(self.repo_dir, "rel-eng")))
self.assertTrue(os.path.exists(os.path.join(self.repo_dir, "rel-eng",
self.assertTrue(os.path.exists(os.path.join(self.repo_dir, ".tito")))
self.assertTrue(os.path.exists(os.path.join(self.repo_dir, ".tito",
"packages")))
self.assertTrue(os.path.exists(os.path.join(self.repo_dir, "rel-eng",
self.assertTrue(os.path.exists(os.path.join(self.repo_dir, ".tito",
"tito.props")))

def test_initial_tag(self):
Expand Down

0 comments on commit 5beaf7a

Please sign in to comment.