Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
Accelerator
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
VegetableChicken-Group
/
WanAndroid_Multi
Public
Notifications
You must be signed in to change notification settings
Fork
15
Star
37
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
framework
Breadcrumbs
WanAndroid_Multi
/
git-hook.gradle.kts
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
56 lines (51 loc) · 1.99 KB
framework
Breadcrumbs
WanAndroid_Multi
/
git-hook.gradle.kts
Copy path
Top
File metadata and controls
Code
Blame
56 lines (51 loc) · 1.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* 操控 Git 钩子文件的脚本
* 使用教程:https://git-scm.com/book/zh/v2/%E8%87%AA%E5%AE%9A%E4%B9%89-Git-Git-%E9%92%A9%E5%AD%90
*
* 由于钩子文件应该放到 .git/hooks 文件下,并且要去掉 .sh 后缀,
* 但为了以后好修改,所以将钩子文件以 sh 文件的形式放在了根项目的 hooks 文件夹下,
* 通过该脚本将文件移动到 .git/hooks 文件夹下
*
* 注意:
* 1、该脚本应该是在根目录下的 build.gradle.kts 中使用
* 2、部分系统可能存在权限问题,无法删除文件
*
*/
/*
* 我也不知道为什么这个文件会提示黄条:This script caused build configguration to fail, run ......
* 但不影响正常运行,所以就不要管它
*
*/
val
hooksFile
=
rootDir.absoluteFile.resolve(
"
hooks
"
)
val
gitHookFile
=
rootDir.absoluteFile.resolve(
"
.git
"
).resolve(
"
hooks
"
)
fun
moveHookFile
(
action
:
((
File
)
->
Unit
)
?
= null) {
hooksFile.listFiles()?.forEach { file
->
val
newFile
=
gitHookFile.resolve(file.name.substringBeforeLast(
"
.sh
"
))
if
(newFile.exists()) {
if
(
!
newFile.delete()) {
println
(
"
${newFile.absolutePath}
删除失败
\n
大概率是 gradle 脚本没有权限删除旧的 hook 文件
\n
请在 git-hook.gradle.kts 中添加权限设置!
"
)
return
}
}
copy {
from(file)
into(newFile.parentFile)
rename { it.substringBeforeLast(
"
.sh
"
) }
}
action?.invoke(file)
}
}
//
将 根目录下的 hooks 移动到 .git/hooks 的 task
//
已生成了 group 为 hook,名字叫 git-hook-move 的任务
val
task
=
tasks.register(
"
git-hook-move
"
) {
group
=
"
hook
"
inputs.dir(hooksFile)
//
gradle 任务缓存设置
outputs.dir(gitHookFile)
//
gradle 任务缓存设置
doFirst {
println
(
"
正在移动 git 钩子文件:
"
)
moveHookFile {
println
(
"
${it.name}
已复制到 .git/hooks 文件下
"
)
}
println
(
"
git 钩子文件移动完毕
"
)
}
}
//
依赖于刷新 gradle 的 task
tasks.getByName(
"
prepareKotlinBuildScriptModel
"
).dependsOn(task)
You can’t perform that action at this time.