Compare commits

...

7 Commits

Author SHA1 Message Date
Mayank Mohapatra
3bb150a7c9
Merge 370284cf608d410cf9670a1ccd98627756671d4e into 40faa6dc78a5b5730a1609ba39daefddac08aa63 2025-02-20 03:35:18 +09:00
ericLemanissier
40faa6dc78
git graph: don't show detached commits (#33645)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-docker-rootful (push) Has been cancelled
release-nightly / nightly-docker-rootless (push) Has been cancelled
Current git graph is not usable for mirrors of repos having a lot of
PRs, as can be seen at
https://demo.gitea.com/ericLemanissier/conan-center-index/graph

![image](https://github.com/user-attachments/assets/ace40dd2-3eea-4d69-8e19-10fb7224e326)


Manually running `git log --graph --date-order --all` on such a repo
indeed shows:
```
*   commit c4a34bd39d7977c8630177c5f88507000ea3e943
|\  Merge: a4bbd3ad6b 35a102c77c
| | Author: toge <toge.mail@gmail.com>
| | Date:   Wed Feb 19 08:36:41 2025 +0000
| |
| |     Merge 35a102c77cbc38d84baca0ca63466fb410336ea8 into a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98
| |
| * commit 35a102c77cbc38d84baca0ca63466fb410336ea8
| | Author: toge <toge.mail@gmail.com>
| | Date:   Wed Feb 19 17:36:35 2025 +0900
| |
| |     update 4.4.2
| |
| | * commit 5d610f4fd3c0428731e402a2f618fad9ce055875
| |/| Merge: a4bbd3ad6b fe916fb70a
|/| | Author: Antony Peacock <ant.peacock@gmail.com>
| | | Date:   Wed Feb 19 08:31:30 2025 +0000
| | |
| | |     Merge fe916fb70a8bf49503cce70a5c7124bcc4314ddc into a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98
| | |
| | * commit fe916fb70a8bf49503cce70a5c7124bcc4314ddc
| | | Author: Antony Peacock <ant.peacock@gmail.com>
| | | Date:   Wed Feb 19 08:31:18 2025 +0000
| | |
| | |     Remove parquet cmakelist patch
| | |
| | | * commit 9f6d2759d650ec3c86d01bb940e829e7e14220c2
| |_|/| Merge: a4bbd3ad6b f0963429b0
|/| | | Author: Thomas Sedlmair <thomas.sedlmair@googlemail.com>
| | | | Date:   Wed Feb 19 08:03:08 2025 +0100
| | | |
| | | |     Merge f0963429b0952499da0da7e559f8d53387097307 into a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98
| | | |
| | | * commit f0963429b0952499da0da7e559f8d53387097307
| |_|/  Author: Thomas Sedlmair <thomas.sedlmair@googlemail.com>
|/| |   Date:   Wed Feb 19 08:01:43 2025 +0100
| | |
| | |       added cwt-cucumber 2.5
| | |
```

On the other hand, running `git log --graph --date-order --branches
--tags` returns the expected:
```
* commit a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98 (HEAD -> master)
| Author: Dan <mstr.danila@gmail.com>
| Date:   Fri Feb 14 18:46:11 2025 +0200
|
|     grpc: add version 1.69.0 (#26446)
|
|     * grpc: add version 1.69.0
|
|     * add cmake tool requires
|
|     ---------
|
|     Co-authored-by: Luis Caro Campos <3535649+jcar87@users.noreply.github.com>
|
* commit a7868807cb2e21206ebf95278cb588f29a3e2205
| Author: Guillaume Egles <gegles@users.noreply.github.com>
| Date:   Thu Feb 13 05:44:35 2025 -0800
|
|     openssl: add versions `3.0.16`, `3.1.8`, `3.2.4`, `3.3.3`, `3.4.1`, stop publishing revisions for version `3.0.15` (#26578)
|
* commit 86057d3e63ac71e2fe48c07bb301f2d54187044d
| Author: Luis Caro Campos <3535649+jcar87@users.noreply.github.com>
| Date:   Thu Feb 13 13:34:41 2025 +0000
|
|     android-ndk: dont set LD and AS variables (#26581)
|
|     * android-ndk: dont set LD and AS variables
|
|     * android-ndk: refactor test package
|
* commit 123e382fafd2f5e811e10faac02efc275c45ec2a
| Author: Nikita <root.kidik@gmail.com>
| Date:   Thu Feb 13 12:29:39 2025 +0300
|
|     libffi: fix conditionals when building on Windows (#26500)
|
|     * fix: add missing or `clang`
|
|     * fix: libffi - always require as tool `automake`
```
2025-02-19 10:35:08 -08:00
Mayank Mohapatra
370284cf60
Merge branch 'main' into notify_action 2025-02-16 17:09:04 +05:30
Mayank Mohapatra
8963c10574 Notify action added
Signed-off-by: Mayank Mohapatra <125661248+Mayank77maruti@users.noreply.github.com>
2025-02-15 01:07:24 +05:30
Mayank Mohapatra
95ee4c6a94 Notify action added
Signed-off-by: Mayank Mohapatra <125661248+Mayank77maruti@users.noreply.github.com>
2025-02-15 00:52:27 +05:30
Mayank Mohapatra
70f02e00ae Notify action added
Signed-off-by: Mayank Mohapatra <125661248+Mayank77maruti@users.noreply.github.com>
2025-02-15 00:43:17 +05:30
Mayank Mohapatra
ba0805520a Notify action added
Signed-off-by: Mayank Mohapatra <125661248+Mayank77maruti@users.noreply.github.com>
2025-02-15 00:24:39 +05:30
6 changed files with 87 additions and 2 deletions

View File

@ -11,7 +11,9 @@ import (
actions_model "code.gitea.io/gitea/models/actions"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/queue"
notify_service "code.gitea.io/gitea/services/notify"
"github.com/nektos/act/pkg/jobparser"
"xorm.io/builder"
@ -70,6 +72,12 @@ func checkJobsOfRun(ctx context.Context, runID int64) error {
}); err != nil {
return err
}
run, _, err := db.GetByID[actions_model.ActionRun](ctx, runID)
if err != nil {
log.Error("GetByID failed: %v", err)
} else if run.Status == actions_model.StatusSuccess || run.Status == actions_model.StatusFailure {
notify_service.ActionRunFinished(ctx, run)
}
CreateCommitStatus(ctx, jobs...)
return nil
}

View File

@ -7,6 +7,7 @@ import (
"context"
"fmt"
actions_model "code.gitea.io/gitea/models/actions"
activities_model "code.gitea.io/gitea/models/activities"
issues_model "code.gitea.io/gitea/models/issues"
repo_model "code.gitea.io/gitea/models/repo"
@ -203,3 +204,63 @@ func (m *mailNotifier) RepoPendingTransfer(ctx context.Context, doer, newOwner *
log.Error("SendRepoTransferNotifyMail: %v", err)
}
}
func (m *mailNotifier) ActionRunFinished(ctx context.Context, run *actions_model.ActionRun) {
// Check status first to avoid unnecessary processing
if run.Status != actions_model.StatusSuccess && run.Status != actions_model.StatusFailure {
return
}
// Load required attributes after status check
if err := run.LoadAttributes(ctx); err != nil {
log.Error("LoadAttributes: %v", err)
return
}
subject := fmt.Sprintf("[%s] Workflow run %s: %s",
run.Repo.FullName(),
run.WorkflowID,
run.Status,
)
// Safely handle short commit SHA
commitSHA := run.CommitSHA
if len(commitSHA) > 7 {
commitSHA = commitSHA[:7]
}
body := fmt.Sprintf(`Workflow "%s" run #%d has completed with status: %s
Repository: %s
Branch: %s
Commit: %s
Triggered by: %s
View the run details here: %s`,
run.WorkflowID,
run.Index,
run.Status,
run.Repo.FullName(),
run.PrettyRef(),
commitSHA,
run.TriggerUser.Name,
run.HTMLURL(),
)
// Send to repo owner if notifications enabled and email present
if run.Repo.Owner.Email != "" &&
run.Repo.Owner.EmailNotificationsPreference != user_model.EmailNotificationsDisabled {
if err := SendMailFrom(ctx, run.Repo.Owner.Email, subject, body); err != nil {
log.Error("Failed to send email to repo owner %s: %v", run.Repo.Owner.Email, err)
}
}
// Send to trigger user if different from owner and notifications enabled
if run.TriggerUser.ID != run.Repo.Owner.ID &&
run.TriggerUser.Email != "" &&
run.TriggerUser.EmailNotificationsPreference != user_model.EmailNotificationsDisabled {
if err := SendMailFrom(ctx, run.TriggerUser.Email, subject, body); err != nil {
log.Error("Failed to send email to trigger user %s: %v", run.TriggerUser.Email, err)
}
}
}

View File

@ -6,6 +6,7 @@ package notify
import (
"context"
actions_model "code.gitea.io/gitea/models/actions"
git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues"
packages_model "code.gitea.io/gitea/models/packages"
@ -76,5 +77,7 @@ type Notifier interface {
ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository)
ActionRunFinished(ctx context.Context, run *actions_model.ActionRun)
CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, commit *repository.PushCommit, sender *user_model.User, status *git_model.CommitStatus)
}

View File

@ -6,6 +6,7 @@ package notify
import (
"context"
actions_model "code.gitea.io/gitea/models/actions"
git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues"
packages_model "code.gitea.io/gitea/models/packages"
@ -374,3 +375,10 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, commit
notifier.CreateCommitStatus(ctx, repo, commit, sender, status)
}
}
// ActionRunFinished represents action run finished
func ActionRunFinished(ctx context.Context, run *actions_model.ActionRun) {
for _, notifier := range notifiers {
notifier.ActionRunFinished(ctx, run)
}
}

View File

@ -6,6 +6,7 @@ package notify
import (
"context"
actions_model "code.gitea.io/gitea/models/actions"
git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues"
packages_model "code.gitea.io/gitea/models/packages"
@ -212,3 +213,7 @@ func (*NullNotifier) ChangeDefaultBranch(ctx context.Context, repo *repo_model.R
func (*NullNotifier) CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, commit *repository.PushCommit, sender *user_model.User, status *git_model.CommitStatus) {
}
// ActionRunFinished represents action run finished
func (*NullNotifier) ActionRunFinished(ctx context.Context, run *actions_model.ActionRun) {}

View File

@ -29,7 +29,7 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo
}
if len(branches) == 0 {
graphCmd.AddArguments("--all")
graphCmd.AddArguments("--tags", "--branches")
}
graphCmd.AddArguments("-C", "-M", "--date=iso-strict").