Skip to content

Conversation

@Kzhou991
Copy link
Collaborator

No description provided.

lateinit var redisOperation: RedisOperation

@Autowired
lateinit var atomReleaseService: AtomReleaseServiceImpl
Copy link
Collaborator

Choose a reason for hiding this comment

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

不要这么依赖,容易造成循环依赖

}
val taskConfigMap = parseTaskJsonToMap(taskJson)
// 检查是否需要使用仓库提交信息作为发布说明
val useRepoCommits = taskConfigMap[USE_REPO_COMMITS_FOR_RELEASE_NOTES] as? Boolean ?: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

从task.json获取提交信息?没有这么要求啊

if (!useRepoCommits) {
return null
}
return getGitRecentCommitMessage(userId, codeSrc, branch)
Copy link
Collaborator

Choose a reason for hiding this comment

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

应该是用户没有主动填版本信息才需要获取仓库的代码提交记录,另外这个逻辑要封装成公用的

@Operation(summary = "根据插件分支获取插件代码库最新提交信息")
@GET
@Path("/desk/atom/release/commitMessage/get")
fun getAtomGitRecentCommitMessage(
Copy link
Collaborator

@carlyin0801 carlyin0801 Aug 20, 2025

Choose a reason for hiding this comment

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

接口要公用

@Parameter(description = "userId", required = true)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "分支", required = true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

非必填字段应该是required = false

@Parameter(description = "gitProjectId", required = false)
@QueryParam("gitProjectId")
gitProjectId: Long? = null,
@Parameter(description = "获取提交信息数量(默认读取最近5条)", required = false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个非空字段又是required = false

)
}

override fun getStoreGitRecentCommitMessages(
Copy link
Collaborator

Choose a reason for hiding this comment

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

改成getRecentGitCommitMessages这个更符合英语特性的名字吧

gitProjectId: Long?,
commitNumber: Int
): String {
val accessToken = client.get(ServiceOauthResource::class).gitGet(userId).data?.accessToken
Copy link
Collaborator

Choose a reason for hiding this comment

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

commitNumber要做下合法性校验,要限制下大小,比如1到10条,不允许用户无限制拉取

// 过滤合并提交信息
val filteredCommits = commits.filter { commit ->
!commit.message.isNullOrBlank() &&
!commit.message!!.trimStart().startsWith("Merge ", ignoreCase = true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这代码要优化下,尽量不要用!!

}
}

override fun getStoreGitRecentCommitMessages(
Copy link
Collaborator

Choose a reason for hiding this comment

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

getStoreGitRecentCommitMessages这个接口放在repository服务更合适

val accessToken = client.get(ServiceOauthResource::class).gitGet(userId).data?.accessToken
if (accessToken.isNullOrBlank()) {
logger.warn("User [$userId] has not performed OAUTH authorization. Please authorize first.")
return ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

accessToken有问题应该直接报错吧

).data?.id

if (projectId == null) {
return ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

projectId 有问题应该直接报错吧

import java.nio.charset.Charset
import java.nio.file.Files
import java.time.LocalDateTime
import java.util.*
Copy link
Collaborator

Choose a reason for hiding this comment

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

ide设置下,不允许.*这种方式导包

private val logger = LoggerFactory.getLogger(GitService::class.java)
private const val MAX_FILE_SIZE = 1 * 1024 * 1024
private const val SLEEP_MILLS_FOR_RETRY = 2000L
private const val MAX_COMMIT_NUMBER = 10
Copy link
Collaborator

Choose a reason for hiding this comment

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

限制数量不要写死了,搞成可配置化

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