Browse Source

feat: Support auto-signature. (#49)

tags/v0.1.0
Asklv GitHub 3 years ago
parent
commit
8ff9824544
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 9 deletions
  1. +0
    -0
      .github/PULL_REQUEST_TEMPLATE.md
  2. +2
    -2
      CONTRIBUTING.md
  3. +14
    -0
      scripts/githooks/commit-msg
  4. +3
    -3
      server/cmd/genhooks/main.go
  5. +3
    -3
      server/cmd/genhooks/pkg/gen.go
  6. +5
    -0
      server/cmd/genhooks/pkg/template.go
  7. +1
    -1
      server/go.mod

+ 0
- 0
.github/PULL_REQUEST_TEMPLATE.md View File


+ 2
- 2
CONTRIBUTING.md View File

@@ -208,7 +208,7 @@ To be honest, we regard every user of OpenKFas a very kind contributor. After ex

Since we collaborate project OpenKF in a distributed way, we appreciate **WELL-WRITTEN**, **DETAILED**, **EXPLICIT** issue reports. To make the communication more efficient, we wish everyone could search if your issue is an existing one in the searching list. If you find it existing, please add your details in comments under the existing issue instead of opening a brand new one.

To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](https://github.com/OpenIMSDK/OpenKF/issues/new/choose) for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please **BE SURE** to follow the instructions to fill fields in template.
To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](https://github.com/OpenIMSDK/.github/tree/main/.github/ISSUE_TEMPLATE) for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please **BE SURE** to follow the instructions to fill fields in template.

**There are a lot of cases when you could open an issue:**

@@ -273,7 +273,7 @@ An example for this could be:

#### PR Description

PR is the only way to make change to OpenKF project files. To help reviewers better get your purpose, **PR** description could not be too detailed. We encourage contributors to follow the [PR template](https://github.com/OpenIMSDK/OpenKF/tree/main/.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request.
PR is the only way to make change to OpenKF project files. To help reviewers better get your purpose, **PR** description could not be too detailed. We encourage contributors to follow the [PR template](https://github.com/OpenIMSDK/.github/blob/main/.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request.

You can find some very formal PR in [RFC](https://github.com/OpenIMSDK/OpenKF/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) issues and learn about them.



+ 14
- 0
scripts/githooks/commit-msg View File

@@ -74,4 +74,18 @@ then
printError "Please fix your commit message to match kubecub coding standards"
printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md"
exit 1
fi

### Add Sign-off-by line to the end of the commit message
# Get local git config
NAME=$(git config user.name)
EMAIL=$(git config user.email)

# Check if the commit message contains a sign-off line
grep -qs "^Signed-off-by: " "$1"
SIGNED_OFF_BY_EXISTS=$?

# Add "Signed-off-by" line if it doesn't exist
if [ $SIGNED_OFF_BY_EXISTS -ne 0 ]; then
echo -e "\nSigned-off-by: $NAME <$EMAIL>" >> "$1"
fi

+ 3
- 3
server/cmd/genhooks/main.go View File

@@ -24,14 +24,14 @@ import (
var (
hookName string
urlPattern string
prority int64
priority int64
savePath string
)

func init() {
flag.StringVar(&hookName, "name", "", "hook name")
flag.StringVar(&urlPattern, "pattern", "", "url pattern")
flag.Int64Var(&prority, "prority", 0, "hook prority")
flag.Int64Var(&priority, "priority", 0, "hook priority")
flag.StringVar(&savePath, "path", "../../internal/middleware/hooks", "save path")
flag.Parse()

@@ -42,5 +42,5 @@ func init() {
}

func main() {
pkg.NewHookGenerator(hookName, urlPattern, savePath, prority).Generate().Format().Flush()
pkg.NewHookGenerator(hookName, urlPattern, savePath, priority).Generate().Format().Flush()
}

+ 3
- 3
server/cmd/genhooks/pkg/gen.go View File

@@ -33,17 +33,17 @@ type HookGenerator struct {
type config struct {
HookName string
UrlPattern string
Prority int64
Priority int64
}

// NewHookGenerator returns a new HookGenerator
func NewHookGenerator(hookName, urlPattern, savePath string, prority int64) *HookGenerator {
func NewHookGenerator(hookName, urlPattern, savePath string, priority int64) *HookGenerator {
return &HookGenerator{
buf: bytes.NewBuffer(nil),
config: &config{
HookName: hookName,
UrlPattern: urlPattern,
Prority: prority,
Priority: priority,
},
savePath: savePath,
}


+ 5
- 0
server/cmd/genhooks/pkg/template.go View File

@@ -56,6 +56,11 @@ func (h {{.HookName}}) Pattern() string {
return "{{.UrlPattern}}"
}

// EDIT THIS TO YOUR OWN HOOK PRIORITY
func (h GlobalHook) Priority() int64 {
return {{.Prority}}
}

// EDIT THIS TO YOUR OWN HOOK BEFORE RUN
func (h {{.HookName}}) BeforeRun(c *gin.Context) {
c.Next()


+ 1
- 1
server/go.mod View File

@@ -1,6 +1,6 @@
module github.com/OpenIMSDK/OpenKF/server

go 1.18
go 1.19

require (
github.com/Delta456/box-cli-maker/v2 v2.3.0


Loading…
Cancel
Save