|
@@ -1,5 +1,7 @@
|
|
|
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Set, Union
|
|
|
|
|
|
+from sentry_relay import parse_release
|
|
|
+
|
|
|
from sentry.models import Activity, CommitFileChange, Project, Team, User
|
|
|
from sentry.notifications.utils import (
|
|
|
get_commits_for_release,
|
|
@@ -37,6 +39,7 @@ class ReleaseActivityNotification(ActivityNotification):
|
|
|
self.repos: Iterable[Mapping[str, Any]] = set()
|
|
|
self.projects: Set[Project] = set()
|
|
|
self.version = "unknown"
|
|
|
+ self.version_parsed = self.version
|
|
|
return
|
|
|
|
|
|
self.projects = set(self.release.projects.all())
|
|
@@ -47,7 +50,9 @@ class ReleaseActivityNotification(ActivityNotification):
|
|
|
self.repos = get_repos(self.commit_list, users, self.organization)
|
|
|
self.environment = get_environment_for_deploy(self.deploy)
|
|
|
self.group_counts_by_project = get_group_counts_by_project(self.release, self.projects)
|
|
|
+
|
|
|
self.version = self.release.version
|
|
|
+ self.version_parsed = parse_release(self.version)["description"]
|
|
|
|
|
|
def should_email(self) -> bool:
|
|
|
return bool(self.release and self.deploy)
|
|
@@ -65,15 +70,16 @@ class ReleaseActivityNotification(ActivityNotification):
|
|
|
def get_context(self) -> MutableMapping[str, Any]:
|
|
|
return {
|
|
|
**self.get_base_context(),
|
|
|
- "commit_count": len(self.commit_list),
|
|
|
"author_count": len(self.email_list),
|
|
|
- "file_count": CommitFileChange.objects.get_count_for_commits(self.commit_list),
|
|
|
- "repos": self.repos,
|
|
|
- "release": self.release,
|
|
|
+ "commit_count": len(self.commit_list),
|
|
|
"deploy": self.deploy,
|
|
|
"environment": self.environment,
|
|
|
+ "file_count": CommitFileChange.objects.get_count_for_commits(self.commit_list),
|
|
|
+ "release": self.release,
|
|
|
+ "repos": self.repos,
|
|
|
"setup_repo_link": absolute_uri(f"/organizations/{self.organization.slug}/repos/"),
|
|
|
- "text_description": f"Version {self.version} was deployed to {self.environment}",
|
|
|
+ "text_description": f"Version {self.version_parsed} was deployed to {self.environment}",
|
|
|
+ "version_parsed": self.version_parsed,
|
|
|
}
|
|
|
|
|
|
def get_projects(self, recipient: Union["Team", "User"]) -> Set[Project]:
|
|
@@ -104,7 +110,7 @@ class ReleaseActivityNotification(ActivityNotification):
|
|
|
}
|
|
|
|
|
|
def get_subject(self, context: Optional[Mapping[str, Any]] = None) -> str:
|
|
|
- return f"Deployed version {self.version} to {self.environment}"
|
|
|
+ return f"Deployed version {self.version_parsed} to {self.environment}"
|
|
|
|
|
|
def get_title(self) -> str:
|
|
|
return self.get_subject()
|
|
@@ -115,7 +121,7 @@ class ReleaseActivityNotification(ActivityNotification):
|
|
|
projects_text = " for this project"
|
|
|
elif len(self.projects) > 1:
|
|
|
projects_text = " for these projects"
|
|
|
- return f"Release {self.version} was deployed to {self.environment}{projects_text}"
|
|
|
+ return f"Release {self.version_parsed} was deployed to {self.environment}{projects_text}"
|
|
|
|
|
|
def get_filename(self) -> str:
|
|
|
return "activity/release"
|