-
Notifications
You must be signed in to change notification settings - Fork 9
Add basic for-each-ref command #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sirnewton01
wants to merge
96
commits into
driusan:master
Choose a base branch
from
sirnewton01:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
4aefef6
Skip the vendor directories with the formatter check
sirnewton01 087e24d
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 6c1aea9
Bring in checkout branch tests
sirnewton01 a8fabeb
Code review feedback
sirnewton01 edf2068
Fix error message in checkout command and add another official checko…
sirnewton01 d08ca51
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 728c693
Add hierarchical branch capabilities and guard against HEAD branch
sirnewton01 0f726df
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 acafa1b
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 4f2e8a6
Code review feedback
sirnewton01 e5505a8
Enable more ignore tests from the official suite
sirnewton01 c452916
Switch to multi-line string for the travis file
sirnewton01 a4a5e0d
Fix travis yml file formatting
sirnewton01 c05883c
Travis script tweak
sirnewton01 56381fc
Tweak run test script
sirnewton01 d08bf4a
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 8ea3379
Add config set suite
sirnewton01 9fbfad7
Fix optional value flags for status subcommand
sirnewton01 a630938
Fix formatting
sirnewton01 7ac6fae
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 0b0216a
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 1945d58
Fix init --bare, detection of bare repos and ls-remote
sirnewton01 1a5ef09
Add global -c parameter for session-scoped configuration values
sirnewton01 1a972f8
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 68d0274
Fix test
sirnewton01 3850dc4
Add max-count options for git log
sirnewton01 77af184
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 d7808c3
Push max commit count checking into rev-list
sirnewton01 e942361
Code review feedback
sirnewton01 cc31e04
Add format option to log, support a subset of formats, add ref name c…
sirnewton01 8e7b699
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 94819b3
Pull commit formatting capability into CommitID
sirnewton01 64e703a
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 526e0f3
Merge conflicts
sirnewton01 e33ae16
Merge conflict
sirnewton01 03b741e
Fix typo
sirnewton01 42e9ad0
Undo depth type change
sirnewton01 dd0adb8
Fix compile errors
sirnewton01 66f37c2
Pull out the building of the ref names list and use it for the medium…
sirnewton01 94c5324
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 ff796db
Show ref names for non-head and non-tag regs in git log
sirnewton01 25b480d
Code review feedback
sirnewton01 37a39fd
Fetch from commit ID
sirnewton01 6778ad8
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 41cde24
Add go get modules tests
sirnewton01 c1c29f2
Add guard against Go 1.10 that doesnt support modules
sirnewton01 cb3757c
Fix exit code for test script
sirnewton01 1f4c0b0
Add support for fetching commit in V1 protocol
sirnewton01 d25722e
Add Go 1.12 to travis
sirnewton01 fabdb79
Make modules test use a package outside of GOPATH
sirnewton01 f863944
Add branch force flag and config unsetall
sirnewton01 443a622
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 bd1ef23
Fix listing hierarchical branches and tags
sirnewton01 fb0c512
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 7c25534
Fix error handles in GetBranches
sirnewton01 dab93ed
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 0f18088
Fix error handling bug in TagList
sirnewton01 941a1aa
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 c376761
Fix slice out of bounds problems in fetchpack when reading from the e…
sirnewton01 a4da4e4
Prevent over-reading error from sideband channel
sirnewton01 6efd331
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 462839a
Improve error reporting on invalid pack files
sirnewton01 77d0b96
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 99cdf59
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 1209db9
Read the remote and refspec to fetch from configuration
sirnewton01 524d38a
Fix leftover fmt.Printf
sirnewton01 6ab9eac
Add official fetch tests
sirnewton01 43c9058
Run official tests outside of make
sirnewton01 ddd09d4
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 7115297
Add verbose flags when running t5510 in case of problems
sirnewton01 d6718cc
Add more verbose debugging of the intermittent test failure
sirnewton01 bd19e5e
Add more verbose debugging of the intermittent test failure
sirnewton01 563a2a8
Add more verbose debugging of the intermittent test failure
sirnewton01 93bc571
Emit stack traces for debugging purposes
sirnewton01 df7a357
Emit stack traces for debugging purposes
sirnewton01 86a92b1
Show commit ID
sirnewton01 ef61241
Temporarily disable cache
sirnewton01 63efb35
Fix formatting and turn off extra debugging of the test
sirnewton01 7a948d9
Add more logging to track down the cause of race condition
sirnewton01 63ce2e7
More logging information
sirnewton01 df15b12
Add more logging
sirnewton01 7536e71
Reduce logging to flush out the error
sirnewton01 3180dc5
Dump branch information
sirnewton01 cb412c3
Dump branch information
sirnewton01 92a0bb6
zip up the git directories
sirnewton01 bf119a2
Use base64 instead and zip recurse
sirnewton01 9625835
Fix indexpack check and add more details about unhandled types
sirnewton01 506bb22
Remove unneeded logging information
sirnewton01 968885b
Review feedbac
sirnewton01 73cedc5
Add 1503 tests
sirnewton01 004f5a9
Hook up hash option to show-ref command
sirnewton01 34c5ed1
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 1cb66f6
Update output to actually show only the sha1 hash
sirnewton01 31d418b
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 2f214f2
Add basic for-each-ref command
sirnewton01 8893223
Fix formatting
sirnewton01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "flag" | ||
| "fmt" | ||
| "os" | ||
| "strings" | ||
|
|
||
| "github.com/driusan/dgit/git" | ||
| ) | ||
|
|
||
| func ForEachRef(c *git.Client, args []string) error { | ||
| flags := flag.NewFlagSet("for-each-ref", flag.ExitOnError) | ||
| flags.SetOutput(flag.CommandLine.Output()) | ||
| flags.Usage = func() { | ||
| flag.Usage() | ||
| fmt.Fprintf(flag.CommandLine.Output(), "\n\nOptions:\n") | ||
| flags.PrintDefaults() | ||
| } | ||
|
|
||
| // These flags can be moved out of these lists and below as proper flags as they are implemented | ||
| for _, sf := range []string{"format"} { | ||
| flags.Var(newNotimplStringValue(), sf, "Not implemented") | ||
| } | ||
|
|
||
| flags.Parse(args) | ||
| refs, err := git.ShowRef(c, git.ShowRefOptions{}, []string{}) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| patterns := flags.Args() | ||
|
|
||
| for _, ref := range refs { | ||
| if len(patterns) == 0 { | ||
| fmt.Printf("%s %s\t%s\n", ref.Value, "commit", ref.Name) // FIXME check if commit or other object type | ||
| } else { | ||
| for _, pattern := range patterns { | ||
| if strings.HasPrefix(ref.Name, pattern) { // FIXME support actual patterns and match only on path segments | ||
| fmt.Printf("%s %s\t%s\n", ref.Value, "commit", ref.Name) // FIXME check if commit or other object type | ||
| break | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if len(refs) == 0 { | ||
| os.Exit(1) | ||
| } | ||
| return nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this part that does the work should be in the git package to be consistent with other commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sirnewton01 ping.. are you going to get a chance to refactor this, or do you want me to pick it up? I don't think it should be a lot of work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can have a look at doing the refactor at some point. Sorry, just really busy at the moment.