mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
add support for passing in the commit count
This commit is contained in:
parent
1c93f43c11
commit
11e0090257
3 changed files with 18 additions and 5 deletions
|
@ -16,7 +16,7 @@
|
|||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
|
||||
my ($IN, $SHA1, $DIR, $TAR_GZ) = @ARGV;
|
||||
my ($IN, $SHA1, $CNT, $DIR, $TAR_GZ) = @ARGV;
|
||||
open IN, $IN or die "Error reading [$IN]\n";
|
||||
my @lines = <IN>;
|
||||
close IN;
|
||||
|
@ -26,7 +26,7 @@ my ($have_release, $have_source, $have_setup) = (0, 0, 0);
|
|||
my $i = 0;
|
||||
for (@lines) {
|
||||
no warnings 'uninitialized';
|
||||
if (s/^(Release:\s*)(.+?)(%{\?dist})?\s*\n$/$1$2.git.$SHA1$3\n/i) {
|
||||
if (s/^(Release:\s*)(.+?)(%{\?dist})?\s*\n$/$1$2.git.$CNT.$SHA1$3\n/i) {
|
||||
if ($have_release) {
|
||||
die "Duplicate Release line found in [$IN] at line [$i]\n";
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ import commands
|
|||
|
||||
from tito.common import (debug, run_command, error_out, find_git_root,
|
||||
create_tgz, get_build_commit, find_spec_file, get_script_path,
|
||||
get_git_head_commit, get_relative_project_dir, check_tag_exists)
|
||||
get_git_head_commit, get_relative_project_dir, check_tag_exists,
|
||||
get_commit_count)
|
||||
|
||||
DEFAULT_KOJI_OPTS = "build --nowait"
|
||||
DEFAULT_CVS_BUILD_DIR = "cvswork"
|
||||
|
@ -589,11 +590,12 @@ class Builder(object):
|
|||
# spec) Swap out the actual release for one that includes the git
|
||||
# SHA1 we're building for our test package:
|
||||
setup_specfile_script = get_script_path("test-setup-specfile.pl")
|
||||
cmd = "%s %s %s %s-%s %s" % \
|
||||
cmd = "%s %s %s %s %s-%s %s" % \
|
||||
(
|
||||
setup_specfile_script,
|
||||
self.spec_file,
|
||||
self.git_commit_id,
|
||||
self.commit_count,
|
||||
self.project_name,
|
||||
self.display_version,
|
||||
self.tgz_filename,
|
||||
|
@ -623,7 +625,10 @@ class Builder(object):
|
|||
branch.
|
||||
"""
|
||||
if self.test:
|
||||
version = "git-" + get_git_head_commit()
|
||||
head_commit = get_git_head_commit()
|
||||
self.commit_count = get_commit_count(head_commit)
|
||||
version = "git-%s.%s" % (self.commit_count, head_commit)
|
||||
#version = "git-" + head_commit
|
||||
else:
|
||||
version = self.build_version.split("-")[0]
|
||||
return version
|
||||
|
@ -690,6 +695,7 @@ class NoTgzBuilder(Builder):
|
|||
script,
|
||||
self.spec_file,
|
||||
self.git_commit_id,
|
||||
self.commit_count,
|
||||
)
|
||||
run_command(cmd)
|
||||
|
||||
|
|
|
@ -172,6 +172,13 @@ def get_build_commit(tag, test=False):
|
|||
commit_id = run_command('git rev-list --max-count=1 %s' % tag_sha1)
|
||||
return commit_id
|
||||
|
||||
def get_commit_count(commit_id):
|
||||
""" Return the number of commits between the tag and commit_id"""
|
||||
output = run_command(
|
||||
"git describe %s | awk -F '-' '{ print $(NF-1) ; exit }'"
|
||||
% commit_id)
|
||||
return output
|
||||
|
||||
|
||||
def get_git_head_commit():
|
||||
""" Return the SHA1 of the HEAD commit on the current git branch. """
|
||||
|
|
Loading…
Add table
Reference in a new issue