mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
Update based on feedback:
1. Remove PushDir, tito.common.chdir has the same functionality so use that instead. 2. Remove useless override of constructor, it's just extra noise.
This commit is contained in:
parent
f4251b30cd
commit
71c2712e7e
2 changed files with 6 additions and 60 deletions
|
@ -15,4 +15,8 @@ from tito.builder.main import \
|
|||
GitLfsBuilder, \
|
||||
MeadBuilder
|
||||
|
||||
from tito.builder.submodule_aware_builder import \
|
||||
SubmoduleAwareBuilder
|
||||
|
||||
from tito.builder.fetch import FetchBuilder
|
||||
|
||||
|
|
|
@ -18,41 +18,10 @@ and rpms.
|
|||
import os
|
||||
|
||||
from tito.builder import Builder
|
||||
from tito.common import debug, run_command, create_tgz, find_spec_like_file, get_commit_timestamp
|
||||
from tito.common import chdir, debug, run_command, create_tgz, find_spec_like_file, get_commit_timestamp
|
||||
from tito.tar import TarFixer
|
||||
|
||||
|
||||
class PushDir(object):
|
||||
"""
|
||||
Helper class to change directories and restore the same way pushd/popd work in the shell.
|
||||
Usage:
|
||||
# cwd = 'current'
|
||||
with PushDir("into"):
|
||||
# cwd = 'current/into'
|
||||
do_command # cwd is into.
|
||||
# cwd = 'current'
|
||||
"""
|
||||
|
||||
def __init__(self, subdir):
|
||||
self.old_wd = os.getcwd()
|
||||
self.new_wd = None
|
||||
if subdir:
|
||||
self.new_wd = os.path.join(self.old_wd, subdir)
|
||||
|
||||
def __enter__(self):
|
||||
if self.new_wd:
|
||||
self.chdir(self.old_wd, self.new_wd)
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
if self.new_wd:
|
||||
self.chdir(self.new_wd, self.old_wd)
|
||||
|
||||
def chdir(self, old_dir, new_dir):
|
||||
if new_dir:
|
||||
debug('Changing directory from %s to %s' % (old_dir, new_dir))
|
||||
os.chdir(new_dir)
|
||||
|
||||
|
||||
class SubmoduleAwareBuilder(Builder):
|
||||
"""
|
||||
Submodule aware builder class.
|
||||
|
@ -62,33 +31,6 @@ class SubmoduleAwareBuilder(Builder):
|
|||
"""
|
||||
REQUIRED_ARGS = []
|
||||
|
||||
# TODO: drop version
|
||||
def __init__(self, name=None, tag=None, build_dir=None,
|
||||
config=None, user_config=None,
|
||||
args=None, **kwargs):
|
||||
# call the parent super class and let it configure everything
|
||||
Builder.__init__(self, name=name, build_dir=build_dir, config=config,
|
||||
user_config=user_config, args=args, **kwargs)
|
||||
"""
|
||||
name - Package name that is being built.
|
||||
|
||||
version - Version and release being built.
|
||||
|
||||
tag - The git tag being built.
|
||||
|
||||
build_dir - Temporary build directory where we can safely work.
|
||||
|
||||
config - Merged configuration. (global plus package specific)
|
||||
|
||||
user_config - User configuration from ~/.titorc.
|
||||
|
||||
args - Optional arguments specific to each builder. Can be passed
|
||||
in explicitly by user on the CLI, or via a release target config
|
||||
entry. Only for things which vary on invocations of the builder,
|
||||
avoid using these if possible. *Given in the format of a dictionary
|
||||
of lists.*
|
||||
"""
|
||||
|
||||
def _setup_sources(self):
|
||||
"""
|
||||
Create a copy of the git source for the project at the point in time
|
||||
|
@ -130,7 +72,7 @@ class SubmoduleAwareBuilder(Builder):
|
|||
git_archive_cmd = 'git archive --format=tar --prefix=%s/ %s:%s --output=%s' % (
|
||||
prefix, commit, relative_git_dir, dest_tar)
|
||||
|
||||
with PushDir(subdir) as p:
|
||||
with chdir(subdir) as p:
|
||||
run_command(git_archive_cmd)
|
||||
|
||||
# Run git-archive separately if --debug was specified.
|
||||
|
|
Loading…
Add table
Reference in a new issue