mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 10:44:12 +01:00 
			
		
		
		
	Improve job commit description (#30579)
Fix https://github.com/go-gitea/gitea/issues/30567 When job is a schedule:  When it is a normal one:  also add a 'space' behind `:`   --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		
							parent
							
								
									2a6418abb1
								
							
						
					
					
						commit
						2a3906d755
					
				@ -74,6 +74,13 @@ func (run *ActionRun) Link() string {
 | 
				
			|||||||
	return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.Index)
 | 
						return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.Index)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (run *ActionRun) WorkflowLink() string {
 | 
				
			||||||
 | 
						if run.Repo == nil {
 | 
				
			||||||
 | 
							return ""
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s/actions/?workflow=%s", run.Repo.Link(), run.WorkflowID)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RefLink return the url of run's ref
 | 
					// RefLink return the url of run's ref
 | 
				
			||||||
func (run *ActionRun) RefLink() string {
 | 
					func (run *ActionRun) RefLink() string {
 | 
				
			||||||
	refName := git.RefName(run.Ref)
 | 
						refName := git.RefName(run.Ref)
 | 
				
			||||||
@ -156,6 +163,10 @@ func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, err
 | 
				
			|||||||
	return nil, fmt.Errorf("event %s is not a pull request event", run.Event)
 | 
						return nil, fmt.Errorf("event %s is not a pull request event", run.Event)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (run *ActionRun) IsSchedule() bool {
 | 
				
			||||||
 | 
						return run.ScheduleID > 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
 | 
					func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
 | 
				
			||||||
	_, err := db.GetEngine(ctx).ID(repo.ID).
 | 
						_, err := db.GetEngine(ctx).ID(repo.ID).
 | 
				
			||||||
		SetExpr("num_action_runs",
 | 
							SetExpr("num_action_runs",
 | 
				
			||||||
 | 
				
			|||||||
@ -67,6 +67,9 @@ type ViewResponse struct {
 | 
				
			|||||||
			CanRerun          bool       `json:"canRerun"`
 | 
								CanRerun          bool       `json:"canRerun"`
 | 
				
			||||||
			CanDeleteArtifact bool       `json:"canDeleteArtifact"`
 | 
								CanDeleteArtifact bool       `json:"canDeleteArtifact"`
 | 
				
			||||||
			Done              bool       `json:"done"`
 | 
								Done              bool       `json:"done"`
 | 
				
			||||||
 | 
								WorkflowID        string     `json:"workflowID"`
 | 
				
			||||||
 | 
								WorkflowLink      string     `json:"workflowLink"`
 | 
				
			||||||
 | 
								IsSchedule        bool       `json:"isSchedule"`
 | 
				
			||||||
			Jobs              []*ViewJob `json:"jobs"`
 | 
								Jobs              []*ViewJob `json:"jobs"`
 | 
				
			||||||
			Commit            ViewCommit `json:"commit"`
 | 
								Commit            ViewCommit `json:"commit"`
 | 
				
			||||||
		} `json:"run"`
 | 
							} `json:"run"`
 | 
				
			||||||
@ -90,12 +93,10 @@ type ViewJob struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ViewCommit struct {
 | 
					type ViewCommit struct {
 | 
				
			||||||
	LocaleCommit   string     `json:"localeCommit"`
 | 
						ShortSha string     `json:"shortSHA"`
 | 
				
			||||||
	LocalePushedBy string     `json:"localePushedBy"`
 | 
						Link     string     `json:"link"`
 | 
				
			||||||
	ShortSha       string     `json:"shortSHA"`
 | 
						Pusher   ViewUser   `json:"pusher"`
 | 
				
			||||||
	Link           string     `json:"link"`
 | 
						Branch   ViewBranch `json:"branch"`
 | 
				
			||||||
	Pusher         ViewUser   `json:"pusher"`
 | 
					 | 
				
			||||||
	Branch         ViewBranch `json:"branch"`
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ViewUser struct {
 | 
					type ViewUser struct {
 | 
				
			||||||
@ -151,6 +152,9 @@ func ViewPost(ctx *context_module.Context) {
 | 
				
			|||||||
	resp.State.Run.CanRerun = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
 | 
						resp.State.Run.CanRerun = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
 | 
				
			||||||
	resp.State.Run.CanDeleteArtifact = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
 | 
						resp.State.Run.CanDeleteArtifact = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
 | 
				
			||||||
	resp.State.Run.Done = run.Status.IsDone()
 | 
						resp.State.Run.Done = run.Status.IsDone()
 | 
				
			||||||
 | 
						resp.State.Run.WorkflowID = run.WorkflowID
 | 
				
			||||||
 | 
						resp.State.Run.WorkflowLink = run.WorkflowLink()
 | 
				
			||||||
 | 
						resp.State.Run.IsSchedule = run.IsSchedule()
 | 
				
			||||||
	resp.State.Run.Jobs = make([]*ViewJob, 0, len(jobs)) // marshal to '[]' instead fo 'null' in json
 | 
						resp.State.Run.Jobs = make([]*ViewJob, 0, len(jobs)) // marshal to '[]' instead fo 'null' in json
 | 
				
			||||||
	resp.State.Run.Status = run.Status.String()
 | 
						resp.State.Run.Status = run.Status.String()
 | 
				
			||||||
	for _, v := range jobs {
 | 
						for _, v := range jobs {
 | 
				
			||||||
@ -172,12 +176,10 @@ func ViewPost(ctx *context_module.Context) {
 | 
				
			|||||||
		Link: run.RefLink(),
 | 
							Link: run.RefLink(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	resp.State.Run.Commit = ViewCommit{
 | 
						resp.State.Run.Commit = ViewCommit{
 | 
				
			||||||
		LocaleCommit:   ctx.Locale.TrString("actions.runs.commit"),
 | 
							ShortSha: base.ShortSha(run.CommitSHA),
 | 
				
			||||||
		LocalePushedBy: ctx.Locale.TrString("actions.runs.pushed_by"),
 | 
							Link:     fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
 | 
				
			||||||
		ShortSha:       base.ShortSha(run.CommitSHA),
 | 
							Pusher:   pusher,
 | 
				
			||||||
		Link:           fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
 | 
							Branch:   branch,
 | 
				
			||||||
		Pusher:         pusher,
 | 
					 | 
				
			||||||
		Branch:         branch,
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var task *actions_model.ActionTask
 | 
						var task *actions_model.ActionTask
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@
 | 
				
			|||||||
					{{if .Title}}{{.Title}}{{else}}{{ctx.Locale.Tr "actions.runs.empty_commit_message"}}{{end}}
 | 
										{{if .Title}}{{.Title}}{{else}}{{ctx.Locale.Tr "actions.runs.empty_commit_message"}}{{end}}
 | 
				
			||||||
				</a>
 | 
									</a>
 | 
				
			||||||
				<div class="flex-item-body">
 | 
									<div class="flex-item-body">
 | 
				
			||||||
					<b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>:
 | 
										<span><b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>:</span>
 | 
				
			||||||
					{{- if .ScheduleID -}}
 | 
										{{- if .ScheduleID -}}
 | 
				
			||||||
						{{ctx.Locale.Tr "actions.runs.scheduled"}}
 | 
											{{ctx.Locale.Tr "actions.runs.scheduled"}}
 | 
				
			||||||
					{{- else -}}
 | 
										{{- else -}}
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,9 @@
 | 
				
			|||||||
		data-locale-cancel="{{ctx.Locale.Tr "cancel"}}"
 | 
							data-locale-cancel="{{ctx.Locale.Tr "cancel"}}"
 | 
				
			||||||
		data-locale-rerun="{{ctx.Locale.Tr "rerun"}}"
 | 
							data-locale-rerun="{{ctx.Locale.Tr "rerun"}}"
 | 
				
			||||||
		data-locale-rerun-all="{{ctx.Locale.Tr "rerun_all"}}"
 | 
							data-locale-rerun-all="{{ctx.Locale.Tr "rerun_all"}}"
 | 
				
			||||||
 | 
							data-locale-runs-scheduled="{{ctx.Locale.Tr "actions.runs.scheduled"}}"
 | 
				
			||||||
 | 
							data-locale-runs-commit="{{ctx.Locale.Tr "actions.runs.commit"}}"
 | 
				
			||||||
 | 
							data-locale-runs-pushed-by="{{ctx.Locale.Tr "actions.runs.pushed_by"}}"
 | 
				
			||||||
		data-locale-status-unknown="{{ctx.Locale.Tr "actions.status.unknown"}}"
 | 
							data-locale-status-unknown="{{ctx.Locale.Tr "actions.status.unknown"}}"
 | 
				
			||||||
		data-locale-status-waiting="{{ctx.Locale.Tr "actions.status.waiting"}}"
 | 
							data-locale-status-waiting="{{ctx.Locale.Tr "actions.status.waiting"}}"
 | 
				
			||||||
		data-locale-status-running="{{ctx.Locale.Tr "actions.status.running"}}"
 | 
							data-locale-status-running="{{ctx.Locale.Tr "actions.status.running"}}"
 | 
				
			||||||
 | 
				
			|||||||
@ -44,6 +44,9 @@ const sfc = {
 | 
				
			|||||||
        canApprove: false,
 | 
					        canApprove: false,
 | 
				
			||||||
        canRerun: false,
 | 
					        canRerun: false,
 | 
				
			||||||
        done: false,
 | 
					        done: false,
 | 
				
			||||||
 | 
					        workflowID: '',
 | 
				
			||||||
 | 
					        workflowLink: '',
 | 
				
			||||||
 | 
					        isSchedule: false,
 | 
				
			||||||
        jobs: [
 | 
					        jobs: [
 | 
				
			||||||
          // {
 | 
					          // {
 | 
				
			||||||
          //   id: 0,
 | 
					          //   id: 0,
 | 
				
			||||||
@ -338,10 +341,13 @@ export function initRepositoryActionView() {
 | 
				
			|||||||
      approve: el.getAttribute('data-locale-approve'),
 | 
					      approve: el.getAttribute('data-locale-approve'),
 | 
				
			||||||
      cancel: el.getAttribute('data-locale-cancel'),
 | 
					      cancel: el.getAttribute('data-locale-cancel'),
 | 
				
			||||||
      rerun: el.getAttribute('data-locale-rerun'),
 | 
					      rerun: el.getAttribute('data-locale-rerun'),
 | 
				
			||||||
 | 
					      rerun_all: el.getAttribute('data-locale-rerun-all'),
 | 
				
			||||||
 | 
					      scheduled: el.getAttribute('data-locale-runs-scheduled'),
 | 
				
			||||||
 | 
					      commit: el.getAttribute('data-locale-runs-commit'),
 | 
				
			||||||
 | 
					      pushedBy: el.getAttribute('data-locale-runs-pushed-by'),
 | 
				
			||||||
      artifactsTitle: el.getAttribute('data-locale-artifacts-title'),
 | 
					      artifactsTitle: el.getAttribute('data-locale-artifacts-title'),
 | 
				
			||||||
      areYouSure: el.getAttribute('data-locale-are-you-sure'),
 | 
					      areYouSure: el.getAttribute('data-locale-are-you-sure'),
 | 
				
			||||||
      confirmDeleteArtifact: el.getAttribute('data-locale-confirm-delete-artifact'),
 | 
					      confirmDeleteArtifact: el.getAttribute('data-locale-confirm-delete-artifact'),
 | 
				
			||||||
      rerun_all: el.getAttribute('data-locale-rerun-all'),
 | 
					 | 
				
			||||||
      showTimeStamps: el.getAttribute('data-locale-show-timestamps'),
 | 
					      showTimeStamps: el.getAttribute('data-locale-show-timestamps'),
 | 
				
			||||||
      showLogSeconds: el.getAttribute('data-locale-show-log-seconds'),
 | 
					      showLogSeconds: el.getAttribute('data-locale-show-log-seconds'),
 | 
				
			||||||
      showFullScreen: el.getAttribute('data-locale-show-full-screen'),
 | 
					      showFullScreen: el.getAttribute('data-locale-show-full-screen'),
 | 
				
			||||||
@ -382,10 +388,16 @@ export function initRepositoryActionView() {
 | 
				
			|||||||
        </button>
 | 
					        </button>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <div class="action-commit-summary">
 | 
					      <div class="action-commit-summary">
 | 
				
			||||||
        {{ run.commit.localeCommit }}
 | 
					        <span><a class="muted" :href="run.workflowLink"><b>{{ run.workflowID }}</b></a>:</span>
 | 
				
			||||||
        <a class="muted" :href="run.commit.link">{{ run.commit.shortSHA }}</a>
 | 
					        <template v-if="run.isSchedule">
 | 
				
			||||||
        {{ run.commit.localePushedBy }}
 | 
					          {{ locale.scheduled }}
 | 
				
			||||||
        <a class="muted" :href="run.commit.pusher.link">{{ run.commit.pusher.displayName }}</a>
 | 
					        </template>
 | 
				
			||||||
 | 
					        <template v-else>
 | 
				
			||||||
 | 
					          {{ locale.commit }}
 | 
				
			||||||
 | 
					          <a class="muted" :href="run.commit.link">{{ run.commit.shortSHA }}</a>
 | 
				
			||||||
 | 
					          {{ locale.pushedBy }}
 | 
				
			||||||
 | 
					          <a class="muted" :href="run.commit.pusher.link">{{ run.commit.pusher.displayName }}</a>
 | 
				
			||||||
 | 
					        </template>
 | 
				
			||||||
        <span class="ui label tw-max-w-full" v-if="run.commit.shortSHA">
 | 
					        <span class="ui label tw-max-w-full" v-if="run.commit.shortSHA">
 | 
				
			||||||
          <a class="gt-ellipsis" :href="run.commit.branch.link">{{ run.commit.branch.name }}</a>
 | 
					          <a class="gt-ellipsis" :href="run.commit.branch.link">{{ run.commit.branch.name }}</a>
 | 
				
			||||||
        </span>
 | 
					        </span>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user