File tree Expand file tree Collapse file tree 5 files changed +16
-33
lines changed
Expand file tree Collapse file tree 5 files changed +16
-33
lines changed Original file line number Diff line number Diff line change 1818 go-version-file : go.mod
1919
2020 - name : Build
21- run : go build -v ./...
21+ run : go version && go build -v ./...
2222
2323 - name : Test
2424 # -count=2 ensures that test fixtures cleanup after themselves
Original file line number Diff line number Diff line change @@ -18,11 +18,7 @@ Use any of the following for a pain-free installation:
1818 ```
1919 The benefit of this method is that re-running the command will always update to the latest version.
2020* You can download a pre-built binary from the [ releases] page.
21- * If you have the [ ` gh ` ] [ gh ] command available, you can install the latest release
22- of ` dependabot ` using the following command ([ gist source] ( https://gist.github.com/mattt/e09e1ecd76d5573e0517a7622009f06f ) ):
23- ``` shell
24- gh gist view --raw e09e1ecd76d5573e0517a7622009f06f | bash
25- ```
21+ * On Mac, you can run ` brew install dependabot `
2622
2723## Requirements
2824
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
1212)
1313
1414func TestDependabot (t * testing.T ) {
15- err := exec .Command ("go" , "build" , "dependabot.go " ).Run ()
15+ err := exec .Command ("go" , "build" , ". " ).Run ()
1616 if err != nil {
1717 t .Fatal ("failed to build dependabot" )
1818 }
@@ -24,7 +24,7 @@ func TestDependabot(t *testing.T) {
2424 engine := & script.Engine {
2525 Conds : scripttest .DefaultConds (),
2626 Cmds : Commands (),
27- Quiet : ! testing . Verbose () ,
27+ Quiet : false ,
2828 }
2929 env := []string {
3030 "PATH=" + os .Getenv ("PATH" ),
Original file line number Diff line number Diff line change 11package cmd
22
33import (
4- "fmt"
5- "regexp"
4+ "log"
65 "runtime/debug"
76)
87
98// ldflags inserts the version here on release
109var version string
1110
12- var timestampRegex = regexp .MustCompile ("[^a-zA-Z0-9]+" )
13-
1411func Version () string {
1512 if version == "" {
1613 version = "0.0.0-dev"
17- commit := ""
18- timestamp := ""
19- modified := false
20-
21- info , _ := debug .ReadBuildInfo ()
22- for _ , entry := range info .Settings {
23- if entry .Key == "vcs.revision" && len (entry .Value ) >= 7 {
24- commit = entry .Value [:7 ] // short ref
25- }
2614
27- if entry .Key == "vcs.modified" {
28- modified = entry .Value == "true"
29- }
30-
31- if entry .Key == "vcs.time" {
32- timestamp = timestampRegex .ReplaceAllString (entry .Value , "" )
33- }
15+ info , ok := debug .ReadBuildInfo ()
16+ if ! ok {
17+ log .Println ("debug.ReadBuildInfo failed" )
18+ return version
3419 }
35-
36- if modified && timestamp != "" {
37- return fmt .Sprintf ("%s+%s" , version , timestamp )
38- } else if commit != "" {
39- return fmt .Sprintf ("%s+%s" , version , commit )
20+ if info .Main .Version != "" {
21+ version = info .Main .Version
4022 }
4123 }
4224
Original file line number Diff line number Diff line change 1+ # Run the dependabot command
2+ dependabot --version
3+
4+ # example: dependabot version v1.57.1-0.20250218140044-2f3fdc69ebfd
5+ stdout 'dependabot version v\d+.\d+.\d+-(\d+\.)?\d{14}-[a-f0-9]{12}'
You can’t perform that action at this time.
0 commit comments