-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport fixes
- Loading branch information
Showing
7 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,32 @@ | ||
package testutil | ||
|
||
import ( | ||
"fmt" | ||
"golang.org/x/mod/modfile" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// GetBabylonVersion returns babylond version from go.mod | ||
func GetBabylonVersion() (string, error) { | ||
goModPath := filepath.Join("..", "go.mod") | ||
data, err := os.ReadFile(goModPath) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
// Parse the go.mod file | ||
modFile, err := modfile.Parse("go.mod", data, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
const modName = "github.com/babylonlabs-io/babylon" | ||
for _, require := range modFile.Require { | ||
if require.Mod.Path == modName { | ||
return require.Mod.Version, nil | ||
} | ||
} | ||
|
||
return "", fmt.Errorf("module %s not found", modName) | ||
} |