mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-24 04:32: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 strict;
|
||||||
use warnings FATAL => 'all';
|
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";
|
open IN, $IN or die "Error reading [$IN]\n";
|
||||||
my @lines = <IN>;
|
my @lines = <IN>;
|
||||||
close IN;
|
close IN;
|
||||||
|
@ -26,7 +26,7 @@ my ($have_release, $have_source, $have_setup) = (0, 0, 0);
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
for (@lines) {
|
for (@lines) {
|
||||||
no warnings 'uninitialized';
|
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) {
|
if ($have_release) {
|
||||||
die "Duplicate Release line found in [$IN] at line [$i]\n";
|
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,
|
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_git_head_commit, get_relative_project_dir, check_tag_exists,
|
||||||
|
get_commit_count)
|
||||||
|
|
||||||
DEFAULT_KOJI_OPTS = "build --nowait"
|
DEFAULT_KOJI_OPTS = "build --nowait"
|
||||||
DEFAULT_CVS_BUILD_DIR = "cvswork"
|
DEFAULT_CVS_BUILD_DIR = "cvswork"
|
||||||
|
@ -589,11 +590,12 @@ class Builder(object):
|
||||||
# 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:
|
||||||
setup_specfile_script = get_script_path("test-setup-specfile.pl")
|
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,
|
setup_specfile_script,
|
||||||
self.spec_file,
|
self.spec_file,
|
||||||
self.git_commit_id,
|
self.git_commit_id,
|
||||||
|
self.commit_count,
|
||||||
self.project_name,
|
self.project_name,
|
||||||
self.display_version,
|
self.display_version,
|
||||||
self.tgz_filename,
|
self.tgz_filename,
|
||||||
|
@ -623,7 +625,10 @@ class Builder(object):
|
||||||
branch.
|
branch.
|
||||||
"""
|
"""
|
||||||
if self.test:
|
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:
|
else:
|
||||||
version = self.build_version.split("-")[0]
|
version = self.build_version.split("-")[0]
|
||||||
return version
|
return version
|
||||||
|
@ -690,6 +695,7 @@ class NoTgzBuilder(Builder):
|
||||||
script,
|
script,
|
||||||
self.spec_file,
|
self.spec_file,
|
||||||
self.git_commit_id,
|
self.git_commit_id,
|
||||||
|
self.commit_count,
|
||||||
)
|
)
|
||||||
run_command(cmd)
|
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)
|
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):
|
||||||
|
""" 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():
|
def get_git_head_commit():
|
||||||
""" Return the SHA1 of the HEAD commit on the current git branch. """
|
""" Return the SHA1 of the HEAD commit on the current git branch. """
|
||||||
|
|
Loading…
Add table
Reference in a new issue