-
Notifications
You must be signed in to change notification settings - Fork 296
chore: delete the .git directory to prevent accidental commits #2698
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ const os = require('os') | |
| const path = require('path') | ||
| const { remove, ensureDir } = require('fs-extra') | ||
| const fs = require('fs') | ||
| const fse = require('fs-extra') | ||
| const args = process.argv.splice(2) | ||
|
|
||
| const home = os.homedir() | ||
|
|
@@ -22,6 +23,7 @@ async function cloneJdHarmony() { | |
| console.log(`Clone ${platform}, branch: ${branch}`) | ||
|
|
||
| await git.clone(remote, ['-b', branch, '--depth', '1']) | ||
| await fse.remove(path.join(__dirname, '../../packages/JDHarmony/.git')) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification 建议添加错误处理以提高代码健壮性 代码中已经包含了基本的日志记录,但缺少对 try {
await fse.remove(path.join(__dirname, '../../packages/JDHarmony/.git'))
console.log('Git 目录删除成功')
} catch (error) {
console.error('删除 .git 目录时发生错误:', error)
throw error
}🔗 Analysis chain验证 .git 目录的删除操作 为确保 .git 目录被正确删除,建议添加错误处理和日志记录。 运行以下脚本验证删除操作: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# 描述:验证 .git 目录是否被正确删除
# 测试:检查是否存在 .git 目录
fd -H -t d '^\.git$' packages/
Length of output: 32 Script: #!/bin/bash
# 检查目录结构和文件权限
ls -la packages/JDHarmony/
# 检查是否有相关的错误处理代码
rg -A 3 "fse.remove.*\.git" scripts/
# 检查是否有相关的日志记录
rg "console\.(log|error)" scripts/harmony/clone-jdharmony.js
Length of output: 737 |
||
|
|
||
| console.log(`Clone completed successfully.`) | ||
| // 修改文件夹名称 | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
重复导入 fs-extra 模块
第4行已经从
fs-extra导入了remove和ensureDir方法。建议移除重复的导入,直接使用已导入的remove方法。建议应用以下修改:
-const fse = require('fs-extra')然后在第26行使用: