Skip to content

Commit 93deea7

Browse files
committed
init structure
1 parent 6d33012 commit 93deea7

File tree

11 files changed

+230
-1
lines changed

11 files changed

+230
-1
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @GrantBirki

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: gomod
5+
directory: "/"
6+
schedule:
7+
interval: monthly
8+
groups:
9+
go-dependencies:
10+
patterns:
11+
- "*"
12+
13+
- package-ecosystem: github-actions
14+
directory: "/"
15+
groups:
16+
github-actions:
17+
patterns:
18+
- "*"
19+
schedule:
20+
interval: monthly

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Go dependency directories
18+
vendor/
19+
20+
# MacOS
21+
.DS_Store
22+
23+
# Go workspace file
24+
go.work
25+
26+
/gh-combine
27+
/gh-combine.exe
28+
29+
dist/
30+
coverage
31+
coverage.html
32+
33+
tmp/
34+
35+
*.secret

.go-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.22.0

.goreleaser.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
3+
4+
version: 2
5+
6+
before:
7+
hooks:
8+
- go mod tidy
9+
10+
builds:
11+
- main: ./cmd/gh-combine
12+
env:
13+
- CGO_ENABLED=0
14+
goos:
15+
- linux
16+
- darwin
17+
ldflags:
18+
- -s -w -X github.com/github/gh-combine/internal/version.tag={{.Tag}}
19+
20+
archives:
21+
- name_template: "{{ .Os }}-{{ .Arch }}"
22+
format: binary
23+
24+
snapshot:
25+
name_template: "{{ .Tag }}-next"
26+
27+
changelog:
28+
use: github-native
29+
30+
release:
31+
draft: false

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
11
# gh-combine
2-
A gh cli extension to automatically combine multiple pull requests into one
2+
3+
A gh cli extension to automatically combine multiple pull requests into one.
4+
5+
[![build](https://github.com/github/gh-combine/actions/workflows/build.yml/badge.svg)](https://github.com/github/gh-combine/actions/workflows/build.yml)
6+
[![lint](https://github.com/github/gh-combine/actions/workflows/lint.yml/badge.svg)](https://github.com/github/gh-combine/actions/workflows/lint.yml)
7+
[![test](https://github.com/github/gh-combine/actions/workflows/test.yml/badge.svg)](https://github.com/github/gh-combine/actions/workflows/test.yml)
8+
[![release](https://github.com/github/gh-combine/actions/workflows/release.yml/badge.svg)](https://github.com/github/gh-combine/actions/workflows/release.yml)
9+
10+
## Installation 💻
11+
12+
Install this gh cli extension by running the following command:
13+
14+
```bash
15+
gh extension install github/gh-combine
16+
```
17+
18+
### Upgrading
19+
20+
You can upgrade this extension by running the following command:
21+
22+
```bash
23+
gh ext upgrade combine
24+
```
25+
26+
## Usage 🚀
27+
28+
```bash
29+
gh combine TODO
30+
```
31+
32+
Run `gh combine --help` for more information.

cmd/gh-combine/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/github/gh-combine/internal/cmd"
8+
)
9+
10+
func main() {
11+
err := cmd.Run()
12+
13+
if err != nil {
14+
fmt.Println(err)
15+
os.Exit(1)
16+
}
17+
}

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/github/gh-combine
2+
3+
go 1.22.0

internal/cmd/logger.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cmd
2+
3+
import (
4+
"log/slog"
5+
"os"
6+
"strings"
7+
)
8+
9+
var Logger *slog.Logger
10+
11+
func init() {
12+
// Set log level based on environment variable
13+
logLevel := os.Getenv("LOG_LEVEL")
14+
if logLevel == "" {
15+
logLevel = "info" // default to info level
16+
}
17+
18+
// upcase the log level
19+
logLevel = strings.ToUpper(logLevel)
20+
21+
var level slog.Level
22+
switch logLevel {
23+
case "DEBUG":
24+
level = slog.LevelDebug
25+
case "INFO":
26+
level = slog.LevelInfo
27+
case "WARN":
28+
level = slog.LevelWarn
29+
case "ERROR":
30+
level = slog.LevelError
31+
default:
32+
level = slog.LevelInfo
33+
}
34+
35+
opts := &slog.HandlerOptions{
36+
Level: level,
37+
}
38+
39+
handler := slog.NewTextHandler(os.Stdout, opts)
40+
41+
// Configure slog with the specified log level
42+
Logger = slog.New(handler)
43+
}

internal/cmd/root.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/github/gh-combine/internal/version"
7+
)
8+
9+
func Run() error {
10+
Logger.Debug("starting gh-combine", "version", version.String())
11+
_, err := fmt.Println("Running gh-combine")
12+
if err != nil {
13+
return fmt.Errorf("oh no")
14+
}
15+
16+
return nil
17+
}

0 commit comments

Comments
 (0)