-
Notifications
You must be signed in to change notification settings - Fork 7
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: 新增记录变更事件的文件以及日志 #122
base: master
Are you sure you want to change the base?
feat: 新增记录变更事件的文件以及日志 #122
Conversation
filePath := filepath.Join(absPath, ci.ConfigItemSpec.Name) | ||
_, err := os.Stat(filePath) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
// content is not exist | ||
// 记录需要新增的文件 | ||
changeLog.Add = append(changeLog.Add, filepath.Join(ci.ConfigItemSpec.Path, ci.ConfigItemSpec.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该不能用 filepath.Join,直接用 path.Join,filepath.Join 的分隔符会根据操作系统来决定,但是 ci.ConfigItemSpec.Path 默认都是用 / 分隔的,如果在 windows 下会变成 / 和 \ 混合在一起了
@@ -285,6 +310,8 @@ func checkFileExists(absPath string, ci *sfs.ConfigItemMetaV1) (bool, error) { | |||
} | |||
|
|||
if sha != ci.ContentSpec.Signature { | |||
// 记录需要更新的文件 | |||
changeLog.Modif = append(changeLog.Modif, filepath.Join(ci.ConfigItemSpec.Path, ci.ConfigItemSpec.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
} | ||
|
||
// 检查文件路径是否在给定路径数组中 | ||
if _, exists := pathSet[file]; !exists { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也需要在 windows 下验证看看,使用 filepath 会不会有问题,最好是只在真实操作文件的时候使用 filepath.Join,其他时候逻辑判断都用 path.Join
} | ||
|
||
// GetLatestChangeLogFromFile get the last data from the file that records change log | ||
func GetLatestChangeLogFromFile(tempDir string) (*ChangeLog, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数看起来没有被其他地方引用,没用的话就先去掉吧
} | ||
|
||
// recordChangeLog 记录变更日志 | ||
func (r *Release) recordChangeLog() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里 changelog 有一个问题:
用户希望能在后置脚本里读到 changelog,所以 changelog 的写入可能要放到后置脚本之前
要不拆成两个 PR 吧😂,先把发布失败不能回滚的问题解决
No description provided.