Skip to content
Open
Show file tree
Hide file tree
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 Feb 21, 2019
087e24d
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Feb 26, 2019
6c1aea9
Bring in checkout branch tests
sirnewton01 Feb 27, 2019
a8fabeb
Code review feedback
sirnewton01 Feb 27, 2019
edf2068
Fix error message in checkout command and add another official checko…
sirnewton01 Feb 27, 2019
d08ca51
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Feb 27, 2019
728c693
Add hierarchical branch capabilities and guard against HEAD branch
sirnewton01 Feb 27, 2019
0f726df
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Feb 27, 2019
acafa1b
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Feb 27, 2019
4f2e8a6
Code review feedback
sirnewton01 Feb 27, 2019
e5505a8
Enable more ignore tests from the official suite
sirnewton01 Feb 27, 2019
c452916
Switch to multi-line string for the travis file
sirnewton01 Feb 27, 2019
a4a5e0d
Fix travis yml file formatting
sirnewton01 Feb 27, 2019
c05883c
Travis script tweak
sirnewton01 Feb 28, 2019
56381fc
Tweak run test script
sirnewton01 Feb 28, 2019
d08bf4a
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Feb 28, 2019
8ea3379
Add config set suite
sirnewton01 Feb 28, 2019
9fbfad7
Fix optional value flags for status subcommand
sirnewton01 Feb 28, 2019
a630938
Fix formatting
sirnewton01 Feb 28, 2019
7ac6fae
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Feb 28, 2019
0b0216a
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Feb 28, 2019
1945d58
Fix init --bare, detection of bare repos and ls-remote
sirnewton01 Feb 28, 2019
1a5ef09
Add global -c parameter for session-scoped configuration values
sirnewton01 Mar 1, 2019
1a972f8
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 1, 2019
68d0274
Fix test
sirnewton01 Mar 1, 2019
3850dc4
Add max-count options for git log
sirnewton01 Mar 1, 2019
77af184
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 1, 2019
d7808c3
Push max commit count checking into rev-list
sirnewton01 Mar 1, 2019
e942361
Code review feedback
sirnewton01 Mar 1, 2019
cc31e04
Add format option to log, support a subset of formats, add ref name c…
sirnewton01 Mar 1, 2019
8e7b699
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 1, 2019
94819b3
Pull commit formatting capability into CommitID
sirnewton01 Mar 5, 2019
64e703a
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 5, 2019
526e0f3
Merge conflicts
sirnewton01 Mar 5, 2019
e33ae16
Merge conflict
sirnewton01 Mar 5, 2019
03b741e
Fix typo
sirnewton01 Mar 5, 2019
42e9ad0
Undo depth type change
sirnewton01 Mar 5, 2019
dd0adb8
Fix compile errors
sirnewton01 Mar 5, 2019
66f37c2
Pull out the building of the ref names list and use it for the medium…
sirnewton01 Mar 5, 2019
94c5324
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 6, 2019
ff796db
Show ref names for non-head and non-tag regs in git log
sirnewton01 Mar 6, 2019
25b480d
Code review feedback
sirnewton01 Mar 6, 2019
37a39fd
Fetch from commit ID
sirnewton01 Mar 6, 2019
6778ad8
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 6, 2019
41cde24
Add go get modules tests
sirnewton01 Mar 6, 2019
c1c29f2
Add guard against Go 1.10 that doesnt support modules
sirnewton01 Mar 6, 2019
cb3757c
Fix exit code for test script
sirnewton01 Mar 6, 2019
1f4c0b0
Add support for fetching commit in V1 protocol
sirnewton01 Mar 6, 2019
d25722e
Add Go 1.12 to travis
sirnewton01 Mar 7, 2019
fabdb79
Make modules test use a package outside of GOPATH
sirnewton01 Mar 7, 2019
f863944
Add branch force flag and config unsetall
sirnewton01 Mar 7, 2019
443a622
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 7, 2019
bd1ef23
Fix listing hierarchical branches and tags
sirnewton01 Mar 8, 2019
fb0c512
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 8, 2019
7c25534
Fix error handles in GetBranches
sirnewton01 Mar 8, 2019
dab93ed
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 8, 2019
0f18088
Fix error handling bug in TagList
sirnewton01 Mar 8, 2019
941a1aa
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 8, 2019
c376761
Fix slice out of bounds problems in fetchpack when reading from the e…
sirnewton01 Mar 8, 2019
a4da4e4
Prevent over-reading error from sideband channel
sirnewton01 Mar 8, 2019
6efd331
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 8, 2019
462839a
Improve error reporting on invalid pack files
sirnewton01 Mar 8, 2019
77d0b96
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 10, 2019
99cdf59
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 10, 2019
1209db9
Read the remote and refspec to fetch from configuration
sirnewton01 Mar 10, 2019
524d38a
Fix leftover fmt.Printf
sirnewton01 Mar 10, 2019
6ab9eac
Add official fetch tests
sirnewton01 Mar 10, 2019
43c9058
Run official tests outside of make
sirnewton01 Mar 10, 2019
ddd09d4
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 10, 2019
7115297
Add verbose flags when running t5510 in case of problems
sirnewton01 Mar 11, 2019
d6718cc
Add more verbose debugging of the intermittent test failure
sirnewton01 Mar 11, 2019
bd19e5e
Add more verbose debugging of the intermittent test failure
sirnewton01 Mar 11, 2019
563a2a8
Add more verbose debugging of the intermittent test failure
sirnewton01 Mar 11, 2019
93bc571
Emit stack traces for debugging purposes
sirnewton01 Mar 11, 2019
df7a357
Emit stack traces for debugging purposes
sirnewton01 Mar 11, 2019
86a92b1
Show commit ID
sirnewton01 Mar 11, 2019
ef61241
Temporarily disable cache
sirnewton01 Mar 11, 2019
63efb35
Fix formatting and turn off extra debugging of the test
sirnewton01 Mar 11, 2019
7a948d9
Add more logging to track down the cause of race condition
sirnewton01 Mar 11, 2019
63ce2e7
More logging information
sirnewton01 Mar 11, 2019
df15b12
Add more logging
sirnewton01 Mar 11, 2019
7536e71
Reduce logging to flush out the error
sirnewton01 Mar 11, 2019
3180dc5
Dump branch information
sirnewton01 Mar 11, 2019
cb412c3
Dump branch information
sirnewton01 Mar 12, 2019
92a0bb6
zip up the git directories
sirnewton01 Mar 12, 2019
bf119a2
Use base64 instead and zip recurse
sirnewton01 Mar 12, 2019
9625835
Fix indexpack check and add more details about unhandled types
sirnewton01 Mar 12, 2019
506bb22
Remove unneeded logging information
sirnewton01 Mar 13, 2019
968885b
Review feedbac
sirnewton01 Mar 13, 2019
73cedc5
Add 1503 tests
sirnewton01 Mar 13, 2019
004f5a9
Hook up hash option to show-ref command
sirnewton01 Mar 13, 2019
34c5ed1
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 13, 2019
1cb66f6
Update output to actually show only the sha1 hash
sirnewton01 Mar 13, 2019
31d418b
Merge branch 'master' of https://github.com/driusan/dgit
sirnewton01 Mar 14, 2019
2f214f2
Add basic for-each-ref command
sirnewton01 Mar 14, 2019
8893223
Fix formatting
sirnewton01 Mar 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions cmd/foreachref.go
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{})
Copy link
Owner

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.

Copy link
Owner

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.

Copy link
Collaborator Author

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.

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
}
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ func main() {
fmt.Fprintln(os.Stderr, err)
os.Exit(4)
}
case "for-each-ref":
subcommandUsage = "[<pattern>...]"
if err := cmd.ForEachRef(c, args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(4)
}
case "ls-remote":
subcommandUsage = "[repo [<patterns>..]]"
if err := cmd.LsRemote(c, args); err != nil {
Expand Down