Skip to content

Commit

Permalink
Revert "Move Go With Replace Detector to the Standard Go Detector" (#…
Browse files Browse the repository at this point in the history
…1198)

* Revert "go detector (#1194)"

This reverts commit 39058c5.

* Update ServiceCollectionExtensions.cs

* Update ServiceCollectionExtensions.cs
  • Loading branch information
amitla1 authored Jul 10, 2024
1 parent 683f30e commit 0707d99
Show file tree
Hide file tree
Showing 6 changed files with 1,101 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public GoComponentDetector(

public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Go };

public override int Version => 8;
public override int Version => 7;

protected override Task<IObservable<ProcessRequest>> OnPrepareDetectionAsync(
IObservable<ProcessRequest> processRequests, IDictionary<string, string> detectorArgs)
Expand Down Expand Up @@ -282,7 +282,6 @@ private async Task ParseGoModFileAsync(
GoGraphTelemetryRecord goGraphTelemetryRecord)
{
using var reader = new StreamReader(file.Stream);
var startString = "require ";

// There can be multiple require( ) sections in go 1.17+. loop over all of them.
while (!reader.EndOfStream)
Expand All @@ -298,9 +297,9 @@ private async Task ParseGoModFileAsync(

// In go >= 1.17, direct dependencies are listed as "require x/y v1.2.3", and transitive dependencies
// are listed in the require () section
if (line.StartsWith(startString))
if (line.StartsWith("require "))
{
this.TryRegisterDependencyFromModLine(line[startString.Length..], singleFileComponentRecorder);
this.TryRegisterDependencyFromModLine(line[8..], singleFileComponentRecorder);
}

line = await reader.ReadLineAsync();
Expand Down Expand Up @@ -444,15 +443,7 @@ private void RecordBuildDependencies(string goListOutput, ISingleFileComponentRe
continue;
}

GoComponent goComponent;
if (dependency.Replace != null)
{
goComponent = new GoComponent(dependency.Replace.Path, dependency.Replace.Version);
}
else
{
goComponent = new GoComponent(dependency.Path, dependency.Version);
}
var goComponent = new GoComponent(dependency.Path, dependency.Version);

if (dependency.Indirect)
{
Expand Down Expand Up @@ -492,7 +483,5 @@ private class GoBuildModule
public string Version { get; set; }

public bool Indirect { get; set; }

public GoBuildModule Replace { get; set; }
}
}
Loading

0 comments on commit 0707d99

Please sign in to comment.