From 60b0d00d9cdee85da9de752095852ddc984d716c Mon Sep 17 00:00:00 2001 From: Samuel Chai Date: Sun, 10 Aug 2025 19:07:31 -0400 Subject: [PATCH 1/3] Add test files --- feature-file.txt | 1 + test-file.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 feature-file.txt create mode 100644 test-file.txt diff --git a/feature-file.txt b/feature-file.txt new file mode 100644 index 0000000..c227b30 --- /dev/null +++ b/feature-file.txt @@ -0,0 +1 @@ +Feature content diff --git a/test-file.txt b/test-file.txt new file mode 100644 index 0000000..8430408 --- /dev/null +++ b/test-file.txt @@ -0,0 +1 @@ +Initial content From 231a44ac6db3536554d1a9ee63c14c169be3b50f Mon Sep 17 00:00:00 2001 From: Samuel Chai Date: Sun, 10 Aug 2025 19:20:18 -0400 Subject: [PATCH 2/3] Main changes --- README.md | 31 +++++++++++++++++++++++++++++++ cmd/args.go | 9 +++++---- cmd/execute.go | 5 +++-- cmd/gh.go | 7 ++++--- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e02ad8b..6390262 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ gh commit -B main -A -d | -A | --all | `bool` | Include all tracked files with changes | | -U | --untracked | `bool` | Include untracked files (requires `--all`) | | -d | --dry-run | `bool` | Show which files would be committed, without committing | +| -b | --base-commit | `string` | Specify a specific commit SHA to use as the base for the new commit | +| -f | --allow-fast-forward | `bool` | Allow fast-forward operations when using --base-commit | | -V | --version | `bool` | Show version | | -h | --help | `bool` | Show help text | @@ -80,6 +82,35 @@ Signed commits are automatically created when using GitHub Actions. --- +## 🔄 Base Commit and Fast-Forward + +The `--base-commit` flag allows you to specify a specific commit SHA to use as the base for your new commit. This is particularly useful for: + +- **Avoiding duplicate commits** after rebases +- **Simulating force pushes** without actually force pushing +- **Maintaining clean commit history** in PRs + +### Usage Examples + +**Basic base commit usage:** +```bash +gh commit -B main -m "fix: update configs" -b a1b2c3d4e5f6789012345678901234567890abcd file.txt +``` + +**With fast-forward (simulates force push):** +```bash +gh commit -B main -m "fix: update configs" -b a1b2c3d4e5f6789012345678901234567890abcd -f file.txt +``` + +### How It Works + +- **`--base-commit` only**: Creates a new commit on top of the specified commit, but doesn't modify the branch pointer +- **`--base-commit` + `--allow-fast-forward`**: Fast-forwards the branch to the specified commit, then creates the new commit on top + +This effectively simulates a force push by allowing you to "rewrite history" from a specific point, preventing the "Update is not a fast forward" error. + +--- + ## 📂 Project Structure - `cmd/` diff --git a/cmd/args.go b/cmd/args.go index 21b16f8..e720627 100644 --- a/cmd/args.go +++ b/cmd/args.go @@ -3,15 +3,16 @@ package cmd import ( "errors" "fmt" + "log" + "os" + "strings" + "text/tabwriter" + "github.com/cli/go-gh" "github.com/fatih/color" "github.com/google/uuid" "github.com/olekukonko/tablewriter" "github.com/spf13/cobra" - "log" - "os" - "strings" - "text/tabwriter" ) type Flag struct { diff --git a/cmd/execute.go b/cmd/execute.go index 5de408a..9da2d28 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -2,12 +2,13 @@ package cmd import ( "fmt" + "os" + "text/tabwriter" + "github.com/cli/go-gh/pkg/api" "github.com/cli/go-gh/pkg/repository" "github.com/fatih/color" "github.com/spf13/cobra" - "os" - "text/tabwriter" ) // VERSION number: changed in CI diff --git a/cmd/gh.go b/cmd/gh.go index 14214d2..d42baae 100644 --- a/cmd/gh.go +++ b/cmd/gh.go @@ -6,12 +6,13 @@ import ( "encoding/json" "errors" "fmt" - "github.com/cli/go-gh" - "github.com/cli/go-gh/pkg/api" - "github.com/fatih/color" "net/http" "os" "strconv" + + "github.com/cli/go-gh" + "github.com/cli/go-gh/pkg/api" + "github.com/fatih/color" ) func ValidateGitRemote() (*RepoSettings, error) { From 1e5b209cadcd654d1697b47b67b97dfc55ffa1dd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 10 Aug 2025 23:36:14 +0000 Subject: [PATCH 3/3] Updating tracked Git version in source code --- cmd/execute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/execute.go b/cmd/execute.go index 9da2d28..d2156dd 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -12,7 +12,7 @@ import ( ) // VERSION number: changed in CI -const VERSION = "v0.2.4" +const VERSION = "v0.2.5" var rootPath string var repo repository.Repository