mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-17 05:52:13 +09:00
fix(actions): never show negative running durations (#39322)
This commit is contained in:
@@ -87,7 +87,7 @@ func calculateDuration(started, stopped timeutil.TimeStamp, status Status, fallb
|
||||
}
|
||||
return end.AsTime().Sub(s)
|
||||
}
|
||||
return timeSince(s).Truncate(time.Second)
|
||||
return max(timeSince(s), 0).Truncate(time.Second)
|
||||
}
|
||||
|
||||
// best effort function to convert an action schedule to action run, to be used in GenerateGiteaContext
|
||||
|
||||
@@ -73,6 +73,14 @@ func Test_calculateDuration(t *testing.T) {
|
||||
},
|
||||
want: 500 * time.Second,
|
||||
},
|
||||
{
|
||||
name: "running started in the future",
|
||||
args: args{
|
||||
started: 1005,
|
||||
status: StatusRunning,
|
||||
},
|
||||
want: 0,
|
||||
},
|
||||
{
|
||||
name: "done",
|
||||
args: args{
|
||||
|
||||
Reference in New Issue
Block a user