1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 22:56:15 +01:00

Merge pull request #1238 from dmach/buildhist-fix-package-checkout

buildhist: Fix running from a package checkout
This commit is contained in:
Daniel Mach 2023-02-01 10:59:28 +01:00 committed by GitHub
commit cce4301bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 4 deletions

View File

@ -0,0 +1,30 @@
Feature: `osc buildhist` command
# common steps for all scenarios
Background:
Given I set working directory to "{context.osc.temp}"
Scenario: Run `osc buildist <project>/<package> <repository>/<arch>`
When I execute osc with args "buildhist test:factory/test-pkgA standard/x86_64"
Then the exit code is 0
Scenario: Run `osc buildist <repository>/<arch>` from a package checkout
Given I execute osc with args "co test:factory/test-pkgA"
And I set working directory to "{context.osc.temp}/test:factory/test-pkgA"
When I execute osc with args "buildhist standard/x86_64"
Then the exit code is 0
Scenario: Run `osc buildist <repository>/<arch>` from outside a package checkout
When I execute osc with args "buildhist standard/x86_64"
Then the exit code is 1
Scenario: Run `osc buildist <repository>/<arch>` from a project checkout
Given I execute osc with args "co test:factory"
And I set working directory to "{context.osc.temp}/test:factory"
When I execute osc with args "buildhist standard/x86_64"
Then the exit code is 1

View File

@ -47,8 +47,13 @@ class BuildHistory:
"ver_rel": node.get("versrel"),
"build_count": int(node.get("bcnt")),
"time": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(int(node.get("time")))),
"duration": int(node.get("duration")),
}
# duration may not always be available
duration = node.get("duration")
if duration:
item["duration"] = int(duration)
result.append(item)
return result
@ -72,7 +77,7 @@ class BuildHistory:
i["srcmd5"],
f"{i['ver_rel']}.{i['build_count']}",
i["rev"],
i["duration"],
i.get("duration", ""),
)
data.extend(item)

View File

@ -6906,8 +6906,16 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl = self.get_api_url()
args = list(args)
project, package, repository, arch = pop_project_package_repository_arch_from_args(args)
ensure_no_remaining_args(args)
args_backup = args.copy()
try:
args = [".", "."] + args_backup.copy()
project, package, repository, arch = pop_project_package_repository_arch_from_args(args)
ensure_no_remaining_args(args)
except (oscerr.NoWorkingCopy, oscerr.WrongArgs):
args[:] = args_backup.copy()
project, package, repository, arch = pop_project_package_repository_arch_from_args(args)
ensure_no_remaining_args(args)
if opts.multibuild_package:
package = package + ":" + opts.multibuild_package