forked from Shiloh/githaven
8030614386
Fixes #24145 To solve the bug, I added a "computed" `TargetBehind` field to the `Release` model, which indicates the target branch of a release. This is particularly useful if the target branch was deleted in the meantime (or is empty). I also did a micro-optimization in `calReleaseNumCommitsBehind`. Instead of checking that a branch exists and then call `GetBranchCommit`, I immediately call `GetBranchCommit` and handle the `git.ErrNotExist` error. This optimization is covered by the added unit test.
139 lines
2.8 KiB
YAML
139 lines
2.8 KiB
YAML
- id: 1
|
|
repo_id: 1
|
|
publisher_id: 2
|
|
tag_name: "v1.1"
|
|
lower_tag_name: "v1.1"
|
|
target: "master"
|
|
title: "testing-release"
|
|
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
|
num_commits: 10
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 946684800
|
|
|
|
- id: 2
|
|
repo_id: 40
|
|
publisher_id: 2
|
|
tag_name: "v1.1"
|
|
lower_tag_name: "v1.1"
|
|
target: "master"
|
|
title: "testing-release"
|
|
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
|
num_commits: 10
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 946684800
|
|
|
|
- id: 3
|
|
repo_id: 1
|
|
publisher_id: 2
|
|
tag_name: "delete-tag"
|
|
lower_tag_name: "delete-tag"
|
|
target: "master"
|
|
title: "delete-tag"
|
|
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
|
num_commits: 10
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: true
|
|
created_unix: 946684800
|
|
|
|
- id: 4
|
|
repo_id: 1
|
|
publisher_id: 2
|
|
tag_name: "draft-release"
|
|
lower_tag_name: "draft-release"
|
|
target: "master"
|
|
title: "draft-release"
|
|
is_draft: true
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 1619524806
|
|
|
|
- id: 5
|
|
repo_id: 1
|
|
publisher_id: 2
|
|
tag_name: "v1.0"
|
|
lower_tag_name: "v1.0"
|
|
target: "master"
|
|
title: "pre-release"
|
|
note: "some text for a pre release"
|
|
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
|
num_commits: 1
|
|
is_draft: false
|
|
is_prerelease: true
|
|
is_tag: false
|
|
created_unix: 946684800
|
|
|
|
- id: 6
|
|
repo_id: 57
|
|
publisher_id: 2
|
|
tag_name: "v1.0"
|
|
lower_tag_name: "v1.0"
|
|
target: "main"
|
|
title: "v1.0"
|
|
sha1: "a8a700e8c644c783ba2c6e742bb81bf91e244bff"
|
|
num_commits: 3
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 946684801
|
|
|
|
- id: 7
|
|
repo_id: 57
|
|
publisher_id: 2
|
|
tag_name: "v1.1"
|
|
lower_tag_name: "v1.1"
|
|
target: "main"
|
|
title: "v1.1"
|
|
sha1: "cef06e48f2642cd0dc9597b4bea09f4b3f74aad6"
|
|
num_commits: 5
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 946684802
|
|
|
|
- id: 8
|
|
repo_id: 57
|
|
publisher_id: 2
|
|
tag_name: "v2.0"
|
|
lower_tag_name: "v2.0"
|
|
target: "main"
|
|
title: "v2.0"
|
|
sha1: "7197b56fdc75b453f47c9110938cb46a303579fd"
|
|
num_commits: 6
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 946684803
|
|
|
|
- id: 9
|
|
repo_id: 57
|
|
publisher_id: 2
|
|
tag_name: "non-existing-target-branch"
|
|
lower_tag_name: "non-existing-target-branch"
|
|
target: "non-existing"
|
|
title: "non-existing-target-branch"
|
|
sha1: "cef06e48f2642cd0dc9597b4bea09f4b3f74aad6"
|
|
num_commits: 5
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 946684803
|
|
|
|
- id: 10
|
|
repo_id: 57
|
|
publisher_id: 2
|
|
tag_name: "empty-target-branch"
|
|
lower_tag_name: "empty-target-branch"
|
|
target: ""
|
|
title: "empty-target-branch"
|
|
sha1: "cef06e48f2642cd0dc9597b4bea09f4b3f74aad6"
|
|
num_commits: 5
|
|
is_draft: false
|
|
is_prerelease: false
|
|
is_tag: false
|
|
created_unix: 946684803
|