mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Automatically clear stopwatch on merging a PR (#4327)
* Don't display buttons if there are no notices * clear stopwatch on merging a PR * remove redundant gt check * use ctx.Flash as per @bkcsoft comment * stop timer on closing issues/PRs too * updated translation as per review * redirect to login page after successfully activating account * remove unrelated changes * stop timer for issues that are closed via commits too..Not just the 'close' UI button
This commit is contained in:
@@ -1181,6 +1181,12 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
||||
if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
|
||||
|
||||
notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed)
|
||||
|
@@ -17,6 +17,13 @@ func IssueStopwatch(c *context.Context) {
|
||||
if c.Written() {
|
||||
return
|
||||
}
|
||||
|
||||
var showSuccessMessage bool
|
||||
|
||||
if !models.StopwatchExists(c.User.ID, issue.ID) {
|
||||
showSuccessMessage = true
|
||||
}
|
||||
|
||||
if !c.Repo.CanUseTimetracker(issue, c.User) {
|
||||
c.NotFound("CanUseTimetracker", nil)
|
||||
return
|
||||
@@ -27,6 +34,10 @@ func IssueStopwatch(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if showSuccessMessage {
|
||||
c.Flash.Success(c.Tr("repo.issues.tracker_auto_close"))
|
||||
}
|
||||
|
||||
url := issue.HTMLURL()
|
||||
c.Redirect(url, http.StatusSeeOther)
|
||||
}
|
||||
|
@@ -590,12 +590,28 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := stopTimerIfAvailable(ctx.User, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
||||
notification.NotifyMergePullRequest(pr, ctx.User, ctx.Repo.GitRepo)
|
||||
|
||||
log.Trace("Pull request merged: %d", pr.ID)
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
|
||||
}
|
||||
|
||||
func stopTimerIfAvailable(user *models.User, issue *models.Issue) error {
|
||||
|
||||
if models.StopwatchExists(user.ID, issue.ID) {
|
||||
if err := models.CreateOrStopIssueStopwatch(user, issue); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseCompareInfo parse compare info between two commit for preparing pull request
|
||||
func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *git.Repository, *git.PullRequestInfo, string, string) {
|
||||
baseRepo := ctx.Repo.Repository
|
||||
|
Reference in New Issue
Block a user