-
Couldn't load subscription status.
- Fork 511
feat:插件发布时发布描述内容支持读取插件代码库最近提交信息 #12080 #12082
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
base: master
Are you sure you want to change the base?
Conversation
| lateinit var redisOperation: RedisOperation | ||
|
|
||
| @Autowired | ||
| lateinit var atomReleaseService: AtomReleaseServiceImpl |
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.
不要这么依赖,容易造成循环依赖
| } | ||
| val taskConfigMap = parseTaskJsonToMap(taskJson) | ||
| // 检查是否需要使用仓库提交信息作为发布说明 | ||
| val useRepoCommits = taskConfigMap[USE_REPO_COMMITS_FOR_RELEASE_NOTES] as? Boolean ?: false |
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.
从task.json获取提交信息?没有这么要求啊
| if (!useRepoCommits) { | ||
| return null | ||
| } | ||
| return getGitRecentCommitMessage(userId, codeSrc, branch) |
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.
应该是用户没有主动填版本信息才需要获取仓库的代码提交记录,另外这个逻辑要封装成公用的
| @Operation(summary = "根据插件分支获取插件代码库最新提交信息") | ||
| @GET | ||
| @Path("/desk/atom/release/commitMessage/get") | ||
| fun getAtomGitRecentCommitMessage( |
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.
接口要公用
| @Parameter(description = "userId", required = true) | ||
| @HeaderParam(AUTH_HEADER_USER_ID) | ||
| userId: String, | ||
| @Parameter(description = "分支", required = true) |
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.
非必填字段应该是required = false
| @Parameter(description = "gitProjectId", required = false) | ||
| @QueryParam("gitProjectId") | ||
| gitProjectId: Long? = null, | ||
| @Parameter(description = "获取提交信息数量(默认读取最近5条)", required = false) |
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.
这个非空字段又是required = false
| ) | ||
| } | ||
|
|
||
| override fun getStoreGitRecentCommitMessages( |
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.
改成getRecentGitCommitMessages这个更符合英语特性的名字吧
| gitProjectId: Long?, | ||
| commitNumber: Int | ||
| ): String { | ||
| val accessToken = client.get(ServiceOauthResource::class).gitGet(userId).data?.accessToken |
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.
commitNumber要做下合法性校验,要限制下大小,比如1到10条,不允许用户无限制拉取
| // 过滤合并提交信息 | ||
| val filteredCommits = commits.filter { commit -> | ||
| !commit.message.isNullOrBlank() && | ||
| !commit.message!!.trimStart().startsWith("Merge ", ignoreCase = true) |
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.
这代码要优化下,尽量不要用!!
| } | ||
| } | ||
|
|
||
| override fun getStoreGitRecentCommitMessages( |
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.
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 "" |
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.
accessToken有问题应该直接报错吧
| ).data?.id | ||
|
|
||
| if (projectId == null) { | ||
| return "" |
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.
projectId 有问题应该直接报错吧
| import java.nio.charset.Charset | ||
| import java.nio.file.Files | ||
| import java.time.LocalDateTime | ||
| import java.util.* |
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.
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 |
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.
限制数量不要写死了,搞成可配置化
No description provided.