mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
use latest commit instead of HEAD for --test.
This commit is contained in:
parent
37a4f53182
commit
967bf8b0ba
3 changed files with 36 additions and 20 deletions
|
@ -52,9 +52,9 @@ if (not $have_release) {
|
||||||
if (defined $TAR_GZ and not $have_source) {
|
if (defined $TAR_GZ and not $have_source) {
|
||||||
die "The specfile [$IN] does not seem to have Source: line we could use\n";
|
die "The specfile [$IN] does not seem to have Source: line we could use\n";
|
||||||
}
|
}
|
||||||
if (defined $DIR and not $have_setup) {
|
#if (defined $DIR and not $have_setup) {
|
||||||
die "The specfile [$IN] does not seem to have %setup line we could use\n";
|
# die "The specfile [$IN] does not seem to have %setup line we could use\n";
|
||||||
}
|
#}
|
||||||
|
|
||||||
my $OUT = "$IN.$SHA1";
|
my $OUT = "$IN.$SHA1";
|
||||||
open OUT, "> $OUT" or die "Error writing [$OUT]\n";
|
open OUT, "> $OUT" or die "Error writing [$OUT]\n";
|
||||||
|
|
|
@ -21,8 +21,8 @@ import commands
|
||||||
|
|
||||||
from tito.common import (debug, run_command, error_out, find_git_root,
|
from tito.common import (debug, run_command, error_out, find_git_root,
|
||||||
create_tgz, get_build_commit, find_spec_file, get_script_path,
|
create_tgz, get_build_commit, find_spec_file, get_script_path,
|
||||||
get_git_head_commit, get_relative_project_dir, check_tag_exists,
|
get_relative_project_dir, check_tag_exists,
|
||||||
get_commit_count)
|
get_commit_count, get_latest_commit)
|
||||||
|
|
||||||
DEFAULT_KOJI_OPTS = "build --nowait"
|
DEFAULT_KOJI_OPTS = "build --nowait"
|
||||||
DEFAULT_CVS_BUILD_DIR = "cvswork"
|
DEFAULT_CVS_BUILD_DIR = "cvswork"
|
||||||
|
@ -625,10 +625,10 @@ class Builder(object):
|
||||||
branch.
|
branch.
|
||||||
"""
|
"""
|
||||||
if self.test:
|
if self.test:
|
||||||
head_commit = get_git_head_commit()
|
# should get latest commit for given directory *NOT* HEAD
|
||||||
self.commit_count = get_commit_count(head_commit)
|
latest_commit = get_latest_commit(".")
|
||||||
version = "git-%s.%s" % (self.commit_count, head_commit[:7])
|
self.commit_count = get_commit_count(self.build_tag, latest_commit)
|
||||||
#version = "git-" + head_commit
|
version = "git-%s.%s" % (self.commit_count, latest_commit[:7])
|
||||||
else:
|
else:
|
||||||
version = self.build_version.split("-")[0]
|
version = self.build_version.split("-")[0]
|
||||||
return version
|
return version
|
||||||
|
@ -660,7 +660,7 @@ class NoTgzBuilder(Builder):
|
||||||
self._setup_sources()
|
self._setup_sources()
|
||||||
self.ran_tgz = True
|
self.ran_tgz = True
|
||||||
|
|
||||||
source_suffixes = ('.tar.gz', '.tar', '.zip', '.jar')
|
source_suffixes = ('.tar.gz', '.tar', '.zip', '.jar', '.gem')
|
||||||
debug("Scanning for sources.")
|
debug("Scanning for sources.")
|
||||||
for filename in os.listdir(self.rpmbuild_gitcopy):
|
for filename in os.listdir(self.rpmbuild_gitcopy):
|
||||||
for suffix in source_suffixes:
|
for suffix in source_suffixes:
|
||||||
|
@ -689,8 +689,9 @@ class NoTgzBuilder(Builder):
|
||||||
# file we're building off. (note that this is a temp copy of the
|
# file we're building off. (note that this is a temp copy of the
|
||||||
# spec) Swap out the actual release for one that includes the git
|
# spec) Swap out the actual release for one that includes the git
|
||||||
# SHA1 we're building for our test package:
|
# SHA1 we're building for our test package:
|
||||||
|
debug("setup_test_specfile:commit_count = %s" % str(self.commit_count))
|
||||||
script = "test-setup-specfile.pl"
|
script = "test-setup-specfile.pl"
|
||||||
cmd = "%s %s %s" % \
|
cmd = "%s %s %s %s" % \
|
||||||
(
|
(
|
||||||
script,
|
script,
|
||||||
self.spec_file,
|
self.spec_file,
|
||||||
|
|
|
@ -164,7 +164,7 @@ def get_relative_project_dir(project_name, commit):
|
||||||
def get_build_commit(tag, test=False):
|
def get_build_commit(tag, test=False):
|
||||||
""" Return the git commit we should build. """
|
""" Return the git commit we should build. """
|
||||||
if test:
|
if test:
|
||||||
return get_git_head_commit()
|
return get_latest_commit(".")
|
||||||
else:
|
else:
|
||||||
tag_sha1 = run_command(
|
tag_sha1 = run_command(
|
||||||
"git ls-remote ./. --tag %s | awk '{ print $1 ; exit }'"
|
"git ls-remote ./. --tag %s | awk '{ print $1 ; exit }'"
|
||||||
|
@ -172,18 +172,33 @@ def get_build_commit(tag, test=False):
|
||||||
commit_id = run_command('git rev-list --max-count=1 %s' % tag_sha1)
|
commit_id = run_command('git rev-list --max-count=1 %s' % tag_sha1)
|
||||||
return commit_id
|
return commit_id
|
||||||
|
|
||||||
def get_commit_count(commit_id):
|
def get_commit_count(tag, commit_id):
|
||||||
""" Return the number of commits between the tag and commit_id"""
|
""" Return the number of commits between the tag and commit_id"""
|
||||||
output = run_command(
|
# git describe returns either a tag-commitcount-gSHA1 OR
|
||||||
"git describe %s | awk -F '-' '{ print $(NF-1) ; exit }'"
|
# just the tag.
|
||||||
% commit_id)
|
#
|
||||||
return output
|
# so we need to pass in the tag as well.
|
||||||
|
# output = run_command("git describe %s" % commit_id)
|
||||||
|
# if tag == output:
|
||||||
|
# return 0
|
||||||
|
# else:
|
||||||
|
# parse the count from the output
|
||||||
|
output = run_command("git describe %s" % commit_id)
|
||||||
|
|
||||||
|
debug("tag - %s" % tag)
|
||||||
|
debug("output - %s" % output)
|
||||||
|
|
||||||
def get_git_head_commit():
|
if tag != output:
|
||||||
""" Return the SHA1 of the HEAD commit on the current git branch. """
|
# tag-commitcount-gSHA1, we want the penultimate value
|
||||||
return commands.getoutput('git rev-parse --verify HEAD')
|
cnt = output.split("-")[-2]
|
||||||
|
return cnt
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def get_latest_commit(path="."):
|
||||||
|
""" Return the latest git commit for the given path. """
|
||||||
|
commit_id = run_command("git log --pretty=format:%%H --max-count=1 %s" % path)
|
||||||
|
return commit_id
|
||||||
|
|
||||||
def get_commit_timestamp(sha1_or_tag):
|
def get_commit_timestamp(sha1_or_tag):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue