Skip to content

Commit

Permalink
Add git push option for description (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
iqiancheng authored Jan 20, 2025
1 parent 662f553 commit 2ab9cf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/usage/git-push-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ git push -o title=Gist123
git push -o title="My Gist 123"
```

## Change description

```shell
git push -o description="This is my gist description"
```

## Change visibility

```shell
Expand Down
5 changes: 5 additions & 0 deletions internal/hooks/post_receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func PostReceive(in io.Reader, out, er io.Writer) error {
outputSb.WriteString(fmt.Sprintf("Gist title set to \"%s\"\n\n", opts["title"]))
}

if opts["description"] != "" && validator.Var(opts["description"], "max=1000") == nil {
gist.Description = opts["description"]
outputSb.WriteString(fmt.Sprintf("Gist description set to \"%s\"\n\n", opts["description"]))
}

if hasNoCommits, err := git.HasNoCommits(gist.User.Username, gist.Uuid); err != nil {
_, _ = fmt.Fprintln(er, "Failed to check if gist has no commits")
return fmt.Errorf("failed to check if gist has no commits: %w", err)
Expand Down

0 comments on commit 2ab9cf5

Please sign in to comment.