├── .github ├── FUNDING.yml └── workflows │ ├── go-cross.yml │ └── main.yml ├── .gitignore ├── .golangci.yml ├── CONTRIBUTING.md ├── LICENCE ├── Makefile ├── add ├── add_custom.go ├── add_gen.go └── doc.go ├── branch ├── branch.go └── doc.go ├── checkout ├── checkout_custom.go ├── checkout_gen.go └── doc.go ├── clone ├── clone_custom.go ├── clone_gen.go └── doc.go ├── commit ├── cleanup │ └── mode.go ├── commit_custom.go ├── commit_gen.go ├── doc.go └── untracked │ └── mode.go ├── config ├── config_custom.go ├── config_gen.go └── doc.go ├── doc.go ├── fetch ├── doc.go ├── fetch_custom.go └── fetch_gen.go ├── git ├── base.go ├── doc.go └── example_test.go ├── go.mod ├── init ├── doc.go ├── init_custom.go ├── init_gen.go └── init_test.go ├── internal ├── descriptions.json ├── generator.go ├── generator_test.go └── readme.adoc ├── lsfiles ├── doc.go ├── lsfiles_custom.go └── lsfiles_gen.go ├── merge ├── doc.go ├── merge_custom.go └── merge_gen.go ├── notes ├── doc.go ├── notes_custom.go ├── notes_gen.go └── subcommands.go ├── pull ├── doc.go ├── pull_custom.go └── pull_gen.go ├── push ├── doc.go ├── push_custom.go └── push_gen.go ├── readme.md ├── rebase ├── doc.go ├── rebase_custom.go └── rebase_gen.go ├── remote ├── doc.go └── remote.go ├── reset ├── doc.go ├── reset_custom.go └── reset_gen.go ├── revparse ├── doc.go ├── revparse_custom.go └── revparse_gen.go ├── stash ├── doc.go ├── stash_custom.go └── stash_gen.go ├── status ├── doc.go ├── status_custom.go └── status_gen.go ├── tag ├── doc.go ├── tag_custom.go └── tag_gen.go ├── types └── types.go └── worktree ├── doc.go └── worktree.go /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: ldez 2 | ko_fi: ldez_oss 3 | liberapay: ldez 4 | thanks_dev: u/gh/ldez 5 | -------------------------------------------------------------------------------- /.github/workflows/go-cross.yml: -------------------------------------------------------------------------------- 1 | name: Go Matrix 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - main 9 | 10 | jobs: 11 | 12 | cross: 13 | name: Go 14 | runs-on: ${{ matrix.os }} 15 | env: 16 | CGO_ENABLED: 0 17 | 18 | strategy: 19 | matrix: 20 | go-version: [ oldstable, stable ] 21 | os: [ubuntu-latest, macos-latest, windows-latest] 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | - uses: actions/setup-go@v5 26 | with: 27 | go-version: ${{ matrix.go-version }} 28 | 29 | - name: Test 30 | run: go test -v -cover ./... 31 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Main 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | tags: 8 | - v* 9 | pull_request: 10 | branches: 11 | - main 12 | 13 | jobs: 14 | 15 | main: 16 | name: Main Process 17 | runs-on: ubuntu-latest 18 | env: 19 | GO_VERSION: stable 20 | GOLANGCI_LINT_VERSION: v2.0.1 21 | CGO_ENABLED: 0 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | - uses: actions/setup-go@v5 26 | with: 27 | go-version: ${{ env.GO_VERSION }} 28 | 29 | - name: Check and get dependencies 30 | run: | 31 | go mod tidy 32 | git diff --exit-code go.mod 33 | # git diff --exit-code go.sum 34 | 35 | # https://golangci-lint.run/usage/install#other-ci 36 | - name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} 37 | run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} 38 | 39 | - name: Make 40 | run: make 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | .idea/ 3 | cover.out -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | 3 | formatters: 4 | enable: 5 | - gci 6 | - gofumpt 7 | settings: 8 | gofumpt: 9 | extra-rules: true 10 | 11 | linters: 12 | default: all 13 | disable: 14 | - cyclop # duplicate of gocyclo 15 | - dupl 16 | - exhaustive 17 | - exhaustruct 18 | - godot 19 | - lll 20 | - makezero 21 | - nilnil 22 | - nlreturn 23 | - paralleltest 24 | - prealloc 25 | - rowserrcheck # not relevant (SQL) 26 | - sqlclosecheck # not relevant (SQL) 27 | - testpackage 28 | - tparallel 29 | - varnamelen 30 | - wrapcheck 31 | - wsl 32 | 33 | settings: 34 | depguard: 35 | rules: 36 | main: 37 | deny: 38 | - pkg: github.com/instana/testify 39 | desc: not allowed 40 | - pkg: github.com/pkg/errors 41 | desc: Should be replaced by standard lib errors package 42 | forbidigo: 43 | forbid: 44 | - pattern: ^print(ln)?$ 45 | - pattern: ^spew\.Print(f|ln)?$ 46 | - pattern: ^spew\.Dump$ 47 | funlen: 48 | lines: -1 49 | statements: 50 50 | goconst: 51 | min-len: 5 52 | min-occurrences: 3 53 | gocritic: 54 | disabled-checks: 55 | - sloppyReassign 56 | - rangeValCopy 57 | - octalLiteral 58 | - paramTypeCombine # already handle by gofumpt.extra-rules 59 | # settings: 60 | # hugeParam: 61 | # sizeThreshold: 220 # todo must be improved 62 | enabled-tags: 63 | - diagnostic 64 | - style 65 | - performance 66 | gocyclo: 67 | min-complexity: 15 68 | godox: 69 | keywords: 70 | - FIXME 71 | gosec: 72 | excludes: 73 | - G204 74 | govet: 75 | disable: 76 | - fieldalignment 77 | enable-all: true 78 | misspell: 79 | locale: US 80 | ignore-rules: 81 | - hardlinked 82 | - behaviour 83 | mnd: 84 | ignored-functions: 85 | - os.* 86 | perfsprint: 87 | err-error: true 88 | errorf: true 89 | sprintf1: true 90 | strconcat: false 91 | tagliatelle: 92 | case: 93 | rules: 94 | json: snake 95 | 96 | exclusions: 97 | warn-unused: true 98 | presets: 99 | - comments 100 | rules: 101 | - linters: 102 | - funlen 103 | path: (.+)_test.go 104 | - path: branch/branch.go 105 | text: func name will be used as branch.BranchName by other packages 106 | - path: notes/notes_custom.go 107 | text: func name will be used as notes.NotesRef by other packages 108 | - path: doc.go 109 | text: don't use an underscore in package name 110 | - path: internal/generator.go 111 | text: 'G306:' 112 | 113 | issues: 114 | max-issues-per-linter: 0 115 | max-same-issues: 0 116 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Add a new command 4 | 5 | I recommend opening an issue before creating a PR. 6 | 7 | 1. You must create a directory with the name of the command. 8 | 2. Inside this directory, you must create a `doc.go` with a summary of the git command (based of the help of this command). 9 | 3. You must define all the options manually inside [descriptions.json](https://github.com/ldez/go-git-cmd-wrapper/blob/main/internal/descriptions.json). 10 | 4. Optionally, you could create a `_custom.go` inside the command directory to add option(s) which cannot be generated. 11 | 5. You must run `make generate` to generate the `_gen.go` related to the `descriptions.json`. 12 | 6. Inside the command directory, you must add test `_test.go`. 13 | 7. You must add examples inside [example_test.go](https://github.com/ldez/go-git-cmd-wrapper/blob/main/git/example_test.go) 14 | 15 | Additionally, I use [regular expressions](https://github.com/ldez/go-git-cmd-wrapper/blob/main/internal/readme.adoc) to help with the `descriptions.json`, 16 | but the extracted information from the doc or the help is not useable directly, 17 | manual editions are required. 18 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2023 Fernandez Ludovic 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: generate lint lint-fix test 2 | 3 | default: generate lint test 4 | 5 | generate: 6 | go generate -x internal/generator.go 7 | 8 | clean-generate: 9 | rm ./**/*_gen.go 10 | 11 | test: 12 | go test ./... --cover 13 | 14 | lint: 15 | golangci-lint run 16 | 17 | lint-fix: 18 | golangci-lint run --fix 19 | -------------------------------------------------------------------------------- /add/add_custom.go: -------------------------------------------------------------------------------- 1 | package add 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/ldez/go-git-cmd-wrapper/v2/types" 7 | ) 8 | 9 | // HyphenHyphen add `--` 10 | // This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken for command-line options). 11 | func HyphenHyphen(g *types.Cmd) { 12 | g.AddOptions("--") 13 | } 14 | 15 | // PathSpec [...] 16 | // Files to add content from. 17 | // Fileglobs (e.g. *.c) can be given to add all matching files. 18 | // Also a leading directory name (e.g. dir to add dir/file1 and dir/file2) can be given to update the index to match the current state of the directory as a whole (e.g. specifying dir will record not just a file dir/file1 modified in the working tree, a file dir/file2 added to the working tree, but also a file dir/file3 removed from the working tree. 19 | func PathSpec(paths ...string) func(*types.Cmd) { 20 | return func(g *types.Cmd) { 21 | for _, path := range paths { 22 | g.AddOptions(path) 23 | } 24 | } 25 | } 26 | 27 | // Chmod Override the executable bit of the added files. 28 | // The executable bit is only changed in the index, the files on disk are left unchanged. 29 | // --chmod=(+|-)x 30 | func Chmod(value string) func(*types.Cmd) { 31 | return func(g *types.Cmd) { 32 | g.AddOptions(fmt.Sprintf("--chmod=%sx", value)) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /add/add_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by pkg/commands/internal/migrate/cloner/cloner.go. DO NOT EDIT. 2 | 3 | package add 4 | 5 | import "github.com/ldez/go-git-cmd-wrapper/v2/types" 6 | 7 | // All Update the index not only where the working tree has a file matching but also where the index already has an entry. 8 | // This adds, modifies, and removes index entries to match the working tree. 9 | // If no is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories). 10 | // -A, --all, --no-ignore-removal 11 | func All(g *types.Cmd) { 12 | g.AddOptions("--all") 13 | } 14 | 15 | // DryRun Don't actually add the file(s), just show if they exist and/or will be ignored. 16 | // -n, --dry-run 17 | func DryRun(g *types.Cmd) { 18 | g.AddOptions("--dry-run") 19 | } 20 | 21 | // Edit Open the diff vs. 22 | // the index in an editor and let the user edit it. 23 | // After the editor was closed, adjust the hunk headers and apply the patch to the index. 24 | // The intent of this option is to pick and choose lines of the patch to apply, or even to modify the contents of lines to be staged. 25 | // This can be quicker and more flexible than using the interactive hunk selector. 26 | // However, it is easy to confuse oneself and create a patch that does not apply to the index. 27 | // See EDITING PATCHES below. 28 | // -e, --edit 29 | func Edit(g *types.Cmd) { 30 | g.AddOptions("--edit") 31 | } 32 | 33 | // Force Allow adding otherwise ignored files. 34 | // -f, --force 35 | func Force(g *types.Cmd) { 36 | g.AddOptions("--force") 37 | } 38 | 39 | // IgnoreErrors If some files could not be added because of errors indexing them, do not abort the operation, but continue adding the others. 40 | // The command shall still exit with non-zero status. 41 | // The configuration variable add.ignoreErrors can be set to true to make this the default behaviour. 42 | // --ignore-errors 43 | func IgnoreErrors(g *types.Cmd) { 44 | g.AddOptions("--ignore-errors") 45 | } 46 | 47 | // IgnoreMissing This option can only be used together with --dry-run. 48 | // By using this option the user can check if any of the given files would be ignored, no matter if they are already present in the work tree or not. 49 | // --ignore-missing 50 | func IgnoreMissing(g *types.Cmd) { 51 | g.AddOptions("--ignore-missing") 52 | } 53 | 54 | // IntentToAdd Record only the fact that the path will be added later. 55 | // An entry for the path is placed in the index with no content. 56 | // This is useful for, among other things, showing the unstaged content of such files with git diff and committing them with git commit -a. 57 | // -N, --intent-to-add 58 | func IntentToAdd(g *types.Cmd) { 59 | g.AddOptions("--intent-to-add") 60 | } 61 | 62 | // Interactive Add modified contents in the working tree interactively to the index. 63 | // Optional path arguments may be supplied to limit operation to a subset of the working tree. 64 | // See 'Interactive mode' for details. 65 | // -i, --interactive 66 | func Interactive(g *types.Cmd) { 67 | g.AddOptions("--interactive") 68 | } 69 | 70 | // NoAll Update the index by adding new files that are unknown to the index and files modified in the working tree, but ignore files that have been removed from the working tree. 71 | // This option is a no-op when no is used. 72 | // This option is primarily to help users who are used to older versions of Git, whose 'git add ...' was a synonym for 'git add --no-all ...', i.e. ignored removed files. 73 | // --no-all, --ignore-removal 74 | func NoAll(g *types.Cmd) { 75 | g.AddOptions("--no-all") 76 | } 77 | 78 | // Patch Interactively choose hunks of patch between the index and the work tree and add them to the index. 79 | // This gives the user a chance to review the difference before adding modified contents to the index. 80 | // This effectively runs add --interactive, but bypasses the initial command menu and directly jumps to the patch subcommand. 81 | // See “Interactive mode” for details. 82 | // -p, --patch 83 | func Patch(g *types.Cmd) { 84 | g.AddOptions("--patch") 85 | } 86 | 87 | // Refresh Don't add the file(s), but only refresh their stat() information in the index. 88 | // --refresh 89 | func Refresh(g *types.Cmd) { 90 | g.AddOptions("--refresh") 91 | } 92 | 93 | // Update Update the index just where it already has an entry matching . 94 | // This removes as well as modifies index entries to match the working tree, but adds no new files. 95 | // If no is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories). 96 | // -u, --update 97 | func Update(g *types.Cmd) { 98 | g.AddOptions("--update") 99 | } 100 | 101 | // Verbose Be verbose. 102 | // -v, --verbose 103 | func Verbose(g *types.Cmd) { 104 | g.AddOptions("--verbose") 105 | } 106 | -------------------------------------------------------------------------------- /add/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package add git-add - Add file contents to the index. 3 | 4 | # SYNOPSIS 5 | 6 | Reference: https://git-scm.com/docs/git-add 7 | 8 | git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] 9 | [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] 10 | [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] 11 | [--chmod=(+|-)x] [--] [...] 12 | 13 | # DESCRIPTION 14 | 15 | This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore. 16 | 17 | The "index" holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working tree, and before running the commit command, you must use the add command to add any new or modified files to the index. 18 | 19 | This command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run git add again to add the new content to the index. 20 | 21 | The git status command can be used to obtain a summary of which files have changes that are staged for the next commit. 22 | 23 | The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored. The git add command can be used to add ignored files with the -f (force) option. 24 | 25 | Please see git-commit(1) for alternative ways to add content to a commit. 26 | */ 27 | package add 28 | -------------------------------------------------------------------------------- /branch/branch.go: -------------------------------------------------------------------------------- 1 | package branch 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/ldez/go-git-cmd-wrapper/v2/types" 7 | ) 8 | 9 | // Abbrev use digits to display SHA-1s 10 | // --abbrev[=] 11 | func Abbrev(n string) func(*types.Cmd) { 12 | return func(g *types.Cmd) { 13 | g.AddOptions(fmt.Sprintf("--abbrev=%s", n)) 14 | } 15 | } 16 | 17 | // All list both remote-tracking and local branches 18 | // -a, --all 19 | func All(g *types.Cmd) { 20 | g.AddOptions("--all") 21 | } 22 | 23 | // BranchName branch name. 24 | func BranchName(name string) func(*types.Cmd) { 25 | return func(g *types.Cmd) { 26 | g.AddOptions(name) 27 | } 28 | } 29 | 30 | // Color use colored output 31 | // --color[=] 32 | func Color(when string) func(*types.Cmd) { 33 | return func(g *types.Cmd) { 34 | g.AddOptions(fmt.Sprintf("--color=%s", when)) 35 | } 36 | } 37 | 38 | // Column list branches in columns 39 | // --column[=