• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

heathcliff26 / gh-utility / 29607523070

17 Jul 2026 07:26PM UTC coverage: 77.54% (-5.2%) from 82.787%
29607523070

push

github

heathcliff26
Add new commit command

Add option to create signed platform commit.
This uses all changed files and creates a new platform commit using the api.

Signed-off-by: Heathcliff <heathcliff@heathcliff.eu>

254 of 338 new or added lines in 8 files covered. (75.15%)

2 existing lines in 2 files now uncovered.

435 of 561 relevant lines covered (77.54%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pkg/pullrequest/pr.go
1
package pullrequest
2

3
import (
4
        "fmt"
5

6
        "github.com/heathcliff26/gh-utility/pkg/client"
7
        "github.com/heathcliff26/gh-utility/pkg/git"
8
)
9

10
// Commit the current changes to the given branch.
11
// Will force push the branch if needed.
12
// Returns the hashes of the created tree and commit
NEW
13
func Commit(c *client.Client, dir, msg, branch, token string) (string, string, error) {
×
NEW
14
        repo, err := git.OpenRepository(dir)
×
NEW
15
        if err != nil {
×
NEW
16
                return "", "", err
×
NEW
17
        }
×
NEW
18
        treeHash, err := repo.GetTreeHash()
×
NEW
19
        if err != nil {
×
NEW
20
                return "", "", err
×
NEW
21
        }
×
NEW
22
        changedFiles, err := repo.GetChangedFiles()
×
NEW
23
        if err != nil {
×
NEW
24
                return "", "", err
×
NEW
25
        }
×
26

NEW
27
        if len(changedFiles) == 0 {
×
NEW
28
                return "", "", nil
×
NEW
29
        }
×
30

NEW
31
        remote, err := repo.GetRemote()
×
NEW
32
        if err != nil {
×
NEW
33
                return "", "", err
×
NEW
34
        }
×
35

NEW
36
        treeHash, err = c.CreateTree(token, remote, changedFiles, treeHash)
×
NEW
37
        if err != nil {
×
NEW
38
                return "", "", fmt.Errorf("failed to create tree: %w", err)
×
NEW
39
        }
×
40

NEW
41
        commitHash, err := repo.GetCommitHash()
×
NEW
42
        if err != nil {
×
NEW
43
                return treeHash, "", err
×
NEW
44
        }
×
45

NEW
46
        commitHash, err = c.CreateCommit(token, remote, msg, treeHash, []string{commitHash})
×
NEW
47
        if err != nil {
×
NEW
48
                return treeHash, "", fmt.Errorf("failed to create commit: %w", err)
×
NEW
49
        }
×
50

NEW
51
        err = c.CreateOrUpdateBranch(token, remote, branch, commitHash)
×
NEW
52
        if err != nil {
×
NEW
53
                return treeHash, commitHash, fmt.Errorf("failed to create/update branch: %w", err)
×
NEW
54
        }
×
55

NEW
56
        return treeHash, commitHash, nil
×
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc