1- // Package main provides a tool to detect and resolve JFrog module dependencies
2- // by parsing go.mod using `go mod edit -json` and checking for branch availability
3- // in forked repositories.
41package main
52
63import (
@@ -45,17 +42,17 @@ type ModuleVersion struct {
4542
4643// DependencyInfo holds information about a detected dependency
4744type DependencyInfo struct {
48- Name string // Short name like "build-info-go"
49- ModulePath string // Full module path like "github.com/jfrog/build-info-go"
50- Repo string // Repository like "jfrog/build-info-go"
51- Ref string // Branch or tag reference
45+ Name string
46+ ModulePath string
47+ Repo string
48+ Ref string
5249}
5350
5451// jfrogDependencies maps short names to their module paths
5552var jfrogDependencies = map [string ]string {
56- "build-info-go" : "github.com/jfrog/build-info-go" ,
57- "jfrog-client-go" : "github.com/jfrog/jfrog-client-go" ,
58- "jfrog-cli-core" : "github.com/jfrog/jfrog-cli-core/v2" ,
53+ "build-info-go" : "github.com/jfrog/build-info-go" ,
54+ "jfrog-client-go" : "github.com/jfrog/jfrog-client-go" ,
55+ "jfrog-cli-core" : "github.com/jfrog/jfrog-cli-core/v2" ,
5956}
6057
6158func main () {
@@ -91,11 +88,6 @@ func main() {
9188 defer output .Close ()
9289 }
9390
94- fmt .Println ("============================================" )
95- fmt .Println ("Detecting JFrog dependencies..." )
96- fmt .Println ("============================================" )
97- fmt .Printf ("Current branch: %s\n \n " , currentBranch )
98-
9991 // Process each dependency
10092 for name , modulePath := range jfrogDependencies {
10193 info := detectDependency (name , modulePath , replaces , currentBranch )
@@ -162,15 +154,14 @@ func detectDependency(name, modulePath string, replaces map[string]Replace, curr
162154 }
163155 }
164156
165- // Fall back to master
166157 fmt .Printf ("No matching branch for %s, will use default (master)\n " , name )
167158 return nil
168159}
169160
170161// branchExists checks if a branch exists in a GitHub repository
171162func branchExists (repo , branch string ) bool {
172163 if branch == "" || branch == "main" || branch == "master" {
173- return false // Don't try to match main/master, use defaults
164+ return false
174165 }
175166
176167 url := fmt .Sprintf ("https://github.com/%s.git" , repo )
@@ -180,7 +171,6 @@ func branchExists(repo, branch string) bool {
180171 return false
181172 }
182173
183- // If output contains the branch name, it exists
184174 return strings .Contains (string (out ), fmt .Sprintf ("refs/heads/%s" , branch ))
185175}
186176
@@ -201,7 +191,6 @@ func writeOutput(output *os.File, name string, info *DependencyInfo) {
201191 fmt .Fprintf (output , "%s_ref=%s\n " , keyName , ref )
202192 }
203193
204- // Also print for visibility
205194 if info != nil {
206195 fmt .Printf (" %s_repo=%s\n " , keyName , repo )
207196 fmt .Printf (" %s_ref=%s\n " , keyName , ref )
0 commit comments