Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/sentry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ def get_revision():
return None


def get_short_revision(revision):
if not revision:
return ""

return revision[:12]


def get_version():
if __build__:
return f"{__version__}.{__build__}"
Expand Down
14 changes: 7 additions & 7 deletions src/sentry/models/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class Release(Model):
build_number = models.BigIntegerField(null=True)

# HACK HACK HACK
# As a transitionary step we permit release rows to exist multiple times
# As a transitional step we permit release rows to exist multiple times
# where they are "specialized" for a specific project. The goal is to
# later split up releases by project again. This is for instance used
# by the org release listing.
Expand Down Expand Up @@ -735,7 +735,7 @@ def set_refs(self, refs, user, fetch=False):
repos_by_name = {r.name: r for r in repos}
invalid_repos = names - set(repos_by_name.keys())
if invalid_repos:
raise InvalidRepository("Invalid repository names: %s" % ",".join(invalid_repos))
raise InvalidRepository(f"Invalid repository names: {','.join(invalid_repos)}")

self.handle_commit_ranges(refs)

Expand Down Expand Up @@ -1124,8 +1124,8 @@ def follows_semver_versioning_scheme(org_id, project_id, release_version=None):
# ToDo(ahmed): re-visit/replace these conditions once we enable project wide `semver` setting
# A project is said to be following semver versioning schemes if it satisfies the following
# conditions:-
# 1: Atleast one semver compliant in the most recent 3 releases
# 2: Atleast 3 semver compliant releases in the most recent 10 releases
# 1: At least one semver compliant in the most recent 3 releases
# 2: At least 3 semver compliant releases in the most recent 10 releases
if len(releases_list) <= 2:
# Most recent release is considered to decide if project follows semver
follows_semver = releases_list[0].is_semver_release
Expand All @@ -1137,12 +1137,12 @@ def follows_semver_versioning_scheme(org_id, project_id, release_version=None):
# Count number of semver releases in the last ten
semver_matches = sum(map(lambda release: release.is_semver_release, releases_list))

atleast_three_in_last_ten = semver_matches >= 3
atleast_one_in_last_three = any(
at_least_three_in_last_ten = semver_matches >= 3
at_least_one_in_last_three = any(
release.is_semver_release for release in releases_list[0:3]
)

follows_semver = atleast_one_in_last_three and atleast_three_in_last_ten
follows_semver = at_least_one_in_last_three and at_least_three_in_last_ten
cache.set(cache_key, follows_semver, 3600)

# Check release_version that is passed is semver compliant
Expand Down
10 changes: 6 additions & 4 deletions src/sentry/notifications/notifications/activity/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ def get_title(self) -> str:
return self.get_subject()

def get_notification_title(self) -> str:
text = "this project"
if len(self.projects) > 1:
text = "these projects"
return f"Release {self.version[:12]} was deployed to {self.environment} for {text}"
projects_text = ""
if len(self.projects) == 1:
projects_text = " for this project"
elif len(self.projects) > 1:
projects_text = " for these projects"
Comment thread
manuzope marked this conversation as resolved.
return f"Release {self.version} was deployed to {self.environment}{projects_text}"

def get_filename(self) -> str:
return "activity/release"
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/integrations/slack/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def test_deploy(self, mock_func):
attachment, text = get_attachment()
assert (
text
== f"Release {release.version[:12]} was deployed to {self.environment.name} for these projects"
== f"Release {release.version} was deployed to {self.environment.name} for these projects"
)
assert attachment["actions"][0]["text"] == self.project.slug
assert (
Expand Down
10 changes: 5 additions & 5 deletions tests/sentry/models/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,8 @@ def test_follows_semver_with_all_releases_semver_and_non_semver_release_version(
def test_follows_semver_user_accidentally_stopped_using_semver_a_few_times(self):
"""
Test that ensures that when a user accidentally stops using semver versioning for a few
times but there exists atleast one semver compliant release in the last 3 releases and
atleast 3 releases that are semver compliant in the last 10 then we still consider
times but there exists at least one semver compliant release in the last 3 releases and
at least 3 releases that are semver compliant in the last 10 then we still consider
project to be following semantic versioning
"""
proj = self.create_project(organization=self.org)
Expand All @@ -1043,7 +1043,7 @@ def test_follows_semver_user_stops_using_semver(self):
"""
Test that ensures that if a user stops using semver and so the last 3 releases in the last
10 releases are all non-semver releases, then the project does not follow semver anymore
since 1st condition of atleast one semver release in the last 3 has to be a semver
since 1st condition of at least one semver release in the last 3 has to be a semver
release is not satisfied
"""
proj = self.create_project(organization=self.org)
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def test_follows_semver_user_accidentally_uses_semver_a_few_times(self):

def test_follows_semver_user_starts_using_semver(self):
"""
Test that ensures if a user starts using semver by having atleast the last 3 releases
Test that ensures if a user starts using semver by having at least the last 3 releases
using semver then we consider the project to be using semver
"""
proj = self.create_project(organization=self.org)
Expand All @@ -1103,7 +1103,7 @@ def test_follows_semver_user_starts_using_semver(self):

def test_follows_semver_user_starts_using_semver_with_less_than_10_recent_releases(self):
"""
Test that ensures that a project with only 5 (<10) releases and atleast one semver
Test that ensures that a project with only 5 (<10) releases and at least one semver
release in the most recent releases is considered to be following semver
"""
proj = self.create_project(organization=self.org)
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/notifications/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_sends_deployment_notification(self):

assert (
text
== f"Release {release.version[:12]} was deployed to {self.environment.name} for this project"
== f"Release {release.version} was deployed to {self.environment.name} for this project"
)
assert (
attachment["actions"][0]["url"]
Expand Down