Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade carbon to v2.5.6 #989

Merged
merged 19 commits into from
Apr 9, 2025
Merged

Conversation

kuafuRace
Copy link
Contributor

📑 Description

Closes https://github.com/goravel/goravel/issues/

✅ Checks

  • Added test cases for my code

… default global timezone has been changed to `UTC`

- 移除了 Clock 结构体和 clock全局变量
- 使用 carbon包的静态方法替代了大部分功能
- 简化了 timezone 的处理逻辑
- 删除了冗余的 getTimezone 函数
@hwbrzzl
Copy link
Contributor

hwbrzzl commented Apr 4, 2025

Thanks, but CI failed.

@kuafuRace kuafuRace changed the title Upgrade carbon to v2.5.5 feat: upgrade carbon to v2.5.5 Apr 8, 2025
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (v1.15.x@de030af). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             v1.15.x     #989   +/-   ##
==========================================
  Coverage           ?   70.07%           
==========================================
  Files              ?      234           
  Lines              ?    19672           
  Branches           ?        0           
==========================================
  Hits               ?    13785           
  Misses             ?     5225           
  Partials           ?      662           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kuafuRace kuafuRace changed the title feat: upgrade carbon to v2.5.5 feat: upgrade carbon to v2.5.6 Apr 8, 2025
Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR 👍 Just two nitpicks. And could you upgrade carbon to 2.6 for the master branch when you have a chance?


// returns a failed scan error.
// 失败的扫描错误
var failedScanError = func(src interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var failedScanError = func(src interface{}) error {
var failedScanError = func(src any) error {

// returns a invalid timestamp error.
// 无效的时间戳错误
var invalidTimestampError = func(value string) error {
return fmt.Errorf("invalid timestamp %s, please make sure the timestamp is valid", value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The errors in this file can be moved to errors/list.go and use constants here.

@kuafuRace
Copy link
Contributor Author

Amazing PR 👍 Just two nitpicks. And could you upgrade carbon to 2.6 for the master branch when you have a chance?

two nitpicks already completed, review again. Upgrading to version 2.6.x is a big challenge, I will try.

@@ -33,7 +35,7 @@ func (t *Date) Scan(src interface{}) error {
case int64:
c = FromTimestamp(v, DefaultTimezone)
default:
return failedScanError(v)
return errors.CarbonFailedScan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v can be passed to the error: errors.CarbonFailedScan.Args(v), and change: CarbonFailedScan = New("failed to scan %s as carbon")

hwbrzzl
hwbrzzl previously approved these changes Apr 9, 2025
Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

errors/list.go Outdated
@@ -138,4 +138,7 @@ var (
ValidationDuplicateRule = New("duplicate rule name: %s")
ValidationEmptyData = New("data can't be empty")
ValidationEmptyRules = New("rules can't be empty")

CarbonFailedScan = New("failed to scan %s as carbon")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CarbonFailedScan = New("failed to scan %s as carbon")
CarbonFailedScan = New("failed to scan %v as carbon")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
The type of value in CarbonFailedScan is deterministic and does not require assertion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems not?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems not?

image

Sorry, I mistook it for parse error

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hwbrzzl hwbrzzl merged commit ece092a into goravel:v1.15.x Apr 9, 2025
10 of 11 checks passed
@kuafuRace kuafuRace deleted the carbon branch April 11, 2025 04:15
kuafuRace added a commit to go-libraries/framework that referenced this pull request Apr 11, 2025
kuafuRace added a commit to go-libraries/framework that referenced this pull request Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants