Skip to content

Old Git data using#4164

Merged
Maheshkale447 merged 3 commits into
Releases/Betafrom
BugFix/OldDataUsing_Git
Apr 7, 2025
Merged

Old Git data using#4164
Maheshkale447 merged 3 commits into
Releases/Betafrom
BugFix/OldDataUsing_Git

Conversation

@GokulBothe99

@GokulBothe99 GokulBothe99 commented Apr 4, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • New Features

    • Enabled automatic retrieval and application of legacy source control credentials.
    • Introduced dynamic updates for source control settings based on repository URL data.
    • Added a new configuration option for self-healing capabilities related to application model updates.
    • Added a method for reading old source control credentials from the Windows Credential Manager.
  • Refactor

    • Improved validation checks to ensure only valid source control details are applied.
    • Streamlined internal dependency usage for enhanced overall reliability.

@coderabbitai

coderabbitai Bot commented Apr 4, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request refactors source control handling by removing unused using directives and updating methods related to source control properties. The changes introduce a new method for reading legacy credentials in both the interface and its implementation, add null/empty checks in property assignments, and update the logic for setting the source control URL when loading solutions. Additionally, it transitions from direct DLL references to package references for the Ginger.ExecuterService.Contracts.

Changes

File(s) Change Summary
Ginger/.../SourceControlProjectsPage.xaml.cs Removed unused using directives to eliminate unnecessary dependencies.
Ginger/.../IUserProfileOperations.cs
Ginger/.../UserProfileOperations.cs
Added new method ReadOldSourceControlCredentials to the interface and its implementation for retrieving stored legacy credentials.
Ginger/.../UserProfile.cs Enhanced source control property methods with null/empty validations and added GetSourceControlPropertyFromUserProfileUsingURL for URL-based property retrieval with error handling.
Ginger/.../WorkSpace.cs Modified HandleSolutionLoadSourceControl to conditionally set the SourceControl URL, retrieving and updating properties only when the URL is empty.
Ginger/.../Ginger.csproj
Ginger/.../GingerCoreCommon.csproj
Ginger/.../GingerCoreNET.csproj
Ginger/.../GingerCoreNETUnitTest.csproj
Added package reference for Ginger.ExecuterService.Contracts version 25.2.2 and removed previous direct DLL references.
Ginger/.../DynamicExecutionManager.cs Added property ForceUpdateApplicationModel to SelfHealingConfiguration for enhanced configuration options.

Suggested reviewers

  • Maheshkale447

Poem

I'm a nimble rabbit, hopping through the code,
Cleaning up old paths on my digital road.
With credentials read and URLs in line,
My burrow of logic now sparkles and shines.
A joyful dance in code, so concise and neat,
Celebrating each change with a happy little beat!
🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread Ginger/GingerCoreCommon/UserCofig/UserProfile.cs
Comment thread Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs
Comment thread Ginger/GingerCoreNET/UserCofig/UserProfileOperations.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92da2f6 and 7790bca.

⛔ Files ignored due to path filters (1)
  • Ginger/GingerCoreNET/DLLS/Ginger.ExecuterService.Contracts.dll is excluded by !**/*.dll, !**/*.dll
📒 Files selected for processing (7)
  • Ginger/Ginger/Ginger.csproj (1 hunks)
  • Ginger/GingerCoreCommon/GingerCoreCommon.csproj (1 hunks)
  • Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (6 hunks)
  • Ginger/GingerCoreNET/GingerCoreNET.csproj (1 hunks)
  • Ginger/GingerCoreNET/RunLib/DynamicExecutionLib/DynamicExecutionManager.cs (1 hunks)
  • Ginger/GingerCoreNET/UserCofig/UserProfileOperations.cs (1 hunks)
  • Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (1)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/GingerCoreCommon/UserCofig/UserProfile.cs:748-765
Timestamp: 2025-04-01T06:07:47.032Z
Learning: The GetSolutionSourceControlInfo method in UserProfile class, which retrieves or creates a GingerSolution entry for a specific solution GUID, has been confirmed by the developer to be working as expected without issues of duplicate entries.
🧬 Code Definitions (1)
Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (3)
Ginger/GingerCoreCommon/SourceControlLib/GingerSolution.cs (2)
  • SourceControlInfo (47-300)
  • GingerSolution (6-45)
Ginger/GingerCoreCommon/SourceControlLib/SourceControlBase.cs (1)
  • SourceControlBase (35-249)
Ginger/GingerCoreCommon/UserCofig/IUserProfileOperations.cs (1)
  • ReadOldSourceControlCredentials (38-38)
🔇 Additional comments (7)
Ginger/GingerCoreNET/UserCofig/UserProfileOperations.cs (1)

344-360: Well-documented and well-implemented method for legacy credentials retrieval.

The implementation correctly reads old source control credentials from the Windows Credential Manager and includes proper error handling with logging. The XML documentation clearly explains the purpose and parameters of the method.

Ginger/GingerCoreNET/RunLib/DynamicExecutionLib/DynamicExecutionManager.cs (1)

629-629: LGTM: Property assignment for ForceUpdateApplicationModel.

This change properly adds support for the ForceUpdateApplicationModel configuration option in the self-healing system. It correctly maps the value from the runset configuration to the self-healing configuration object.

Ginger/GingerCoreNET/GingerCoreNET.csproj (1)

263-263: Package reference upgrade is a good practice.

Transitioning from direct DLL references to package references improves dependency management. The package Ginger.ExecuterService.Contracts with version 25.2.2 is now properly referenced as a NuGet package.

Ginger/Ginger/Ginger.csproj (1)

724-724: Dependency Update for Ginger.ExecuterService.Contracts

The new package reference for “Ginger.ExecuterService.Contracts” at version “25.2.2” is correctly added here. This update replaces the previously used direct DLL reference, thereby streamlining dependency management and improving version consistency across the solution. Please ensure that all consuming projects have been updated accordingly to avoid any version mismatches.

Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj (1)

92-92: Updated Package Reference in Unit Test Project

The inclusion of the “Ginger.ExecuterService.Contracts” package reference (v25.2.2) in this unit test project is in line with the changes made in other parts of the solution. This change centralizes dependency management and should help prevent issues related to mismatched versions. It would be good to verify that your tests still run as expected after this update.

Ginger/GingerCoreCommon/GingerCoreCommon.csproj (1)

35-49: Standardized Dependency Management Update

A new package reference for “Ginger.ExecuterService.Contracts” has been added (v25.2.2) within this core common project. This change mirrors similar updates in other project files and represents a coordinated migration from direct DLL references to NuGet package management. This should help maintain consistency and simplify future updates. Ensure that any code relying on the old DLL reference is properly adjusted to work with the package.

Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (1)

840-868: No issues with the updated property assignments.
The minor update for AuthorEmail (line 857) matches the surrounding logic.

Comment thread Ginger/GingerCoreCommon/UserCofig/UserProfile.cs Outdated
Comment on lines +874 to +904
/// <summary>
/// Retrieves source control properties from the user profile using the provided URL.
/// </summary>
/// <param name="mSourceControl">The source control object to populate with properties.</param>
/// <param name="solutionGuid">The GUID of the solution.</param>
public void GetSourceControlPropertyFromUserProfileUsingURL(SourceControlBase mSourceControl, Guid solutionGuid)
{
try
{
//old git info stored on 0 node
GingerSolution item = GingerSolutions.Count > 1 ? GingerSolutions[0] : null;
if (item == null)
{
return;
}
if (item.SourceControlInfo.Url == mSourceControl.URL && item.SolutionGuid == Guid.Empty)
{
UserProfileOperations.ReadOldSourceControlCredentials(mSourceControl);
mSourceControl.AuthorName = item.SourceControlInfo.AuthorName;
mSourceControl.AuthorEmail = item.SourceControlInfo.AuthorEmail;
mSourceControl.Branch = item.SourceControlInfo.Branch;
GingerSolutions.RemoveAt(0);
SetSourceControlPropertyOnUserProfile(mSourceControl, solutionGuid);
}

}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Failed to load the old source control configration", ex);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Revisit removing the first solution item and fix the spelling error in the error message.

  1. Removing the first item in GingerSolutions (line 895) may unexpectedly discard solution info. Confirm that this behavior is intentional.
  2. Correct the spelling of “configuration” in line 902.

,

Below is an example fix for the spelling:

-Reporter.ToLog(eLogLevel.ERROR, "Failed to load the old source control configration", ex);
+Reporter.ToLog(eLogLevel.ERROR, "Failed to load the old source control configuration", ex);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// <summary>
/// Retrieves source control properties from the user profile using the provided URL.
/// </summary>
/// <param name="mSourceControl">The source control object to populate with properties.</param>
/// <param name="solutionGuid">The GUID of the solution.</param>
public void GetSourceControlPropertyFromUserProfileUsingURL(SourceControlBase mSourceControl, Guid solutionGuid)
{
try
{
//old git info stored on 0 node
GingerSolution item = GingerSolutions.Count > 1 ? GingerSolutions[0] : null;
if (item == null)
{
return;
}
if (item.SourceControlInfo.Url == mSourceControl.URL && item.SolutionGuid == Guid.Empty)
{
UserProfileOperations.ReadOldSourceControlCredentials(mSourceControl);
mSourceControl.AuthorName = item.SourceControlInfo.AuthorName;
mSourceControl.AuthorEmail = item.SourceControlInfo.AuthorEmail;
mSourceControl.Branch = item.SourceControlInfo.Branch;
GingerSolutions.RemoveAt(0);
SetSourceControlPropertyOnUserProfile(mSourceControl, solutionGuid);
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Failed to load the old source control configration", ex);
}
}
/// <summary>
/// Retrieves source control properties from the user profile using the provided URL.
/// </summary>
/// <param name="mSourceControl">The source control object to populate with properties.</param>
/// <param name="solutionGuid">The GUID of the solution.</param>
public void GetSourceControlPropertyFromUserProfileUsingURL(SourceControlBase mSourceControl, Guid solutionGuid)
{
try
{
//old git info stored on 0 node
GingerSolution item = GingerSolutions.Count > 1 ? GingerSolutions[0] : null;
if (item == null)
{
return;
}
if (item.SourceControlInfo.Url == mSourceControl.URL && item.SolutionGuid == Guid.Empty)
{
UserProfileOperations.ReadOldSourceControlCredentials(mSourceControl);
mSourceControl.AuthorName = item.SourceControlInfo.AuthorName;
mSourceControl.AuthorEmail = item.SourceControlInfo.AuthorEmail;
mSourceControl.Branch = item.SourceControlInfo.Branch;
GingerSolutions.RemoveAt(0);
SetSourceControlPropertyOnUserProfile(mSourceControl, solutionGuid);
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Failed to load the old source control configuration", ex);
}
}

Comment on lines +775 to +830


GingerSolutionSourceControl.SourceControlInfo.Type = mSourceControl.GetSourceControlType;
GingerSolutionSourceControl.SourceControlInfo.Url = mSourceControl.URL;
GingerSolutionSourceControl.SourceControlInfo.Username = mSourceControl.Username;
GingerSolutionSourceControl.SourceControlInfo.Password = mSourceControl.Password;
if (mSourceControl.LocalFolder.EndsWith(".git"))

if (!string.IsNullOrEmpty(mSourceControl.URL))
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder.Substring(0, mSourceControl.LocalFolder.LastIndexOf('\\'));
GingerSolutionSourceControl.SourceControlInfo.Url = mSourceControl.URL;
}
else
if (!string.IsNullOrEmpty(mSourceControl.Username))
{
GingerSolutionSourceControl.SourceControlInfo.Username = mSourceControl.Username;
}
if (!string.IsNullOrEmpty(mSourceControl.Password))
{
GingerSolutionSourceControl.SourceControlInfo.Password = mSourceControl.Password;
}
if (!string.IsNullOrEmpty(mSourceControl.LocalFolder))
{
if (mSourceControl.LocalFolder.EndsWith(".git"))
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder.Substring(0, mSourceControl.LocalFolder.LastIndexOf('\\'));
}
else
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
}
}
if (!string.IsNullOrEmpty(mSourceControl.Branch))
{
GingerSolutionSourceControl.SourceControlInfo.Branch = mSourceControl.Branch;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorName))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorName = mSourceControl.AuthorName;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorEmail))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorEmail = mSourceControl.AuthorEmail;
}
if (mSourceControl.Timeout != 0)
{
GingerSolutionSourceControl.SourceControlInfo.Timeout = mSourceControl.Timeout;
}
if (mSourceControl.IsProxyConfigured)
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
GingerSolutionSourceControl.SourceControlInfo.IsProxyConfigured = mSourceControl.IsProxyConfigured;
}
GingerSolutionSourceControl.SourceControlInfo.Branch = mSourceControl.Branch;
GingerSolutionSourceControl.SourceControlInfo.AuthorName = mSourceControl.AuthorName;
GingerSolutionSourceControl.SourceControlInfo.AuthorEmail = mSourceControl.AuthorEmail;
GingerSolutionSourceControl.SourceControlInfo.Timeout = mSourceControl.Timeout;
GingerSolutionSourceControl.SourceControlInfo.IsProxyConfigured = mSourceControl.IsProxyConfigured;
GingerSolutionSourceControl.SourceControlInfo.ProxyAddress = mSourceControl.ProxyAddress;
GingerSolutionSourceControl.SourceControlInfo.ProxyPort = mSourceControl.ProxyPort;
if (!string.IsNullOrEmpty(mSourceControl.ProxyAddress))
{
GingerSolutionSourceControl.SourceControlInfo.ProxyAddress = mSourceControl.ProxyAddress;
}
if (mSourceControl.ProxyPort != null)
{
GingerSolutionSourceControl.SourceControlInfo.ProxyPort = mSourceControl.ProxyPort;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Prevent potential path errors and validate the timeout value.

  1. Substring extraction for .git paths can fail if there is no \ in the path. This can trigger an out-of-range exception.
  2. Consider also validating that the timeout isn’t negative, given that current logic only checks for != 0.

Below is an example diff addressing the .git substring logic in lines 793-799:

-if (mSourceControl.LocalFolder.EndsWith(".git"))
-{
-    GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath =
-        mSourceControl.LocalFolder.Substring(0, mSourceControl.LocalFolder.LastIndexOf('\\'));
-}
-else
-{
-    GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
-}

+if (!string.IsNullOrEmpty(mSourceControl.LocalFolder))
+{
+    if (mSourceControl.LocalFolder.EndsWith(".git"))
+    {
+        int slashIndex = mSourceControl.LocalFolder.LastIndexOf('\\');
+        if (slashIndex >= 0)
+        {
+            GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath =
+                mSourceControl.LocalFolder.Substring(0, slashIndex);
+        }
+        else
+        {
+            // Fallback: .git found but no slash - handle gracefully
+            GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
+        }
+    }
+    else
+    {
+        GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
+    }
+    // Optional: Validate if Timeout isn't negative as well, e.g.:
+    // if (mSourceControl.Timeout < 0) { /* handle or log warning */ }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
GingerSolutionSourceControl.SourceControlInfo.Type = mSourceControl.GetSourceControlType;
GingerSolutionSourceControl.SourceControlInfo.Url = mSourceControl.URL;
GingerSolutionSourceControl.SourceControlInfo.Username = mSourceControl.Username;
GingerSolutionSourceControl.SourceControlInfo.Password = mSourceControl.Password;
if (mSourceControl.LocalFolder.EndsWith(".git"))
if (!string.IsNullOrEmpty(mSourceControl.URL))
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder.Substring(0, mSourceControl.LocalFolder.LastIndexOf('\\'));
GingerSolutionSourceControl.SourceControlInfo.Url = mSourceControl.URL;
}
else
if (!string.IsNullOrEmpty(mSourceControl.Username))
{
GingerSolutionSourceControl.SourceControlInfo.Username = mSourceControl.Username;
}
if (!string.IsNullOrEmpty(mSourceControl.Password))
{
GingerSolutionSourceControl.SourceControlInfo.Password = mSourceControl.Password;
}
if (!string.IsNullOrEmpty(mSourceControl.LocalFolder))
{
if (mSourceControl.LocalFolder.EndsWith(".git"))
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder.Substring(0, mSourceControl.LocalFolder.LastIndexOf('\\'));
}
else
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
}
}
if (!string.IsNullOrEmpty(mSourceControl.Branch))
{
GingerSolutionSourceControl.SourceControlInfo.Branch = mSourceControl.Branch;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorName))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorName = mSourceControl.AuthorName;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorEmail))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorEmail = mSourceControl.AuthorEmail;
}
if (mSourceControl.Timeout != 0)
{
GingerSolutionSourceControl.SourceControlInfo.Timeout = mSourceControl.Timeout;
}
if (mSourceControl.IsProxyConfigured)
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
GingerSolutionSourceControl.SourceControlInfo.IsProxyConfigured = mSourceControl.IsProxyConfigured;
}
GingerSolutionSourceControl.SourceControlInfo.Branch = mSourceControl.Branch;
GingerSolutionSourceControl.SourceControlInfo.AuthorName = mSourceControl.AuthorName;
GingerSolutionSourceControl.SourceControlInfo.AuthorEmail = mSourceControl.AuthorEmail;
GingerSolutionSourceControl.SourceControlInfo.Timeout = mSourceControl.Timeout;
GingerSolutionSourceControl.SourceControlInfo.IsProxyConfigured = mSourceControl.IsProxyConfigured;
GingerSolutionSourceControl.SourceControlInfo.ProxyAddress = mSourceControl.ProxyAddress;
GingerSolutionSourceControl.SourceControlInfo.ProxyPort = mSourceControl.ProxyPort;
if (!string.IsNullOrEmpty(mSourceControl.ProxyAddress))
{
GingerSolutionSourceControl.SourceControlInfo.ProxyAddress = mSourceControl.ProxyAddress;
}
if (mSourceControl.ProxyPort != null)
{
GingerSolutionSourceControl.SourceControlInfo.ProxyPort = mSourceControl.ProxyPort;
}
GingerSolutionSourceControl.SourceControlInfo.Type = mSourceControl.GetSourceControlType;
if (!string.IsNullOrEmpty(mSourceControl.URL))
{
GingerSolutionSourceControl.SourceControlInfo.Url = mSourceControl.URL;
}
if (!string.IsNullOrEmpty(mSourceControl.Username))
{
GingerSolutionSourceControl.SourceControlInfo.Username = mSourceControl.Username;
}
if (!string.IsNullOrEmpty(mSourceControl.Password))
{
GingerSolutionSourceControl.SourceControlInfo.Password = mSourceControl.Password;
}
if (!string.IsNullOrEmpty(mSourceControl.LocalFolder))
{
if (mSourceControl.LocalFolder.EndsWith(".git"))
{
int slashIndex = mSourceControl.LocalFolder.LastIndexOf('\\');
if (slashIndex >= 0)
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath =
mSourceControl.LocalFolder.Substring(0, slashIndex);
}
else
{
// Fallback: .git found but no slash - handle gracefully
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
}
}
else
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
}
// Optional: Validate if Timeout isn't negative as well, e.g.:
// if (mSourceControl.Timeout < 0) { /* handle or log warning */ }
}
if (!string.IsNullOrEmpty(mSourceControl.Branch))
{
GingerSolutionSourceControl.SourceControlInfo.Branch = mSourceControl.Branch;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorName))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorName = mSourceControl.AuthorName;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorEmail))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorEmail = mSourceControl.AuthorEmail;
}
if (mSourceControl.Timeout != 0)
{
GingerSolutionSourceControl.SourceControlInfo.Timeout = mSourceControl.Timeout;
}
if (mSourceControl.IsProxyConfigured)
{
GingerSolutionSourceControl.SourceControlInfo.IsProxyConfigured = mSourceControl.IsProxyConfigured;
}
if (!string.IsNullOrEmpty(mSourceControl.ProxyAddress))
{
GingerSolutionSourceControl.SourceControlInfo.ProxyAddress = mSourceControl.ProxyAddress;
}
if (mSourceControl.ProxyPort != null)
{
GingerSolutionSourceControl.SourceControlInfo.ProxyPort = mSourceControl.ProxyPort;
}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (1)

881-911: Revisit removing the first item from GingerSolutions.

This new method implements a migration step by removing the first list item if Count > 1 and the URL matches. This might inadvertently discard useful solution info if there is exactly one solution or if the first item is not truly “old” data. The same concern was raised in a previous review on removing the first solution entry. Verify that this logic meets all use cases and does not lead to data loss.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7790bca and 753b1d2.

📒 Files selected for processing (1)
  • Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (1)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4137
File: Ginger/GingerCoreCommon/UserCofig/UserProfile.cs:748-765
Timestamp: 2025-04-01T06:07:47.032Z
Learning: The GetSolutionSourceControlInfo method in UserProfile class, which retrieves or creates a GingerSolution entry for a specific solution GUID, has been confirmed by the developer to be working as expected without issues of duplicate entries.
🧬 Code Definitions (1)
Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (2)
Ginger/GingerCoreCommon/SourceControlLib/GingerSolution.cs (2)
  • SourceControlInfo (47-300)
  • GingerSolution (6-45)
Ginger/GingerCoreCommon/UserCofig/IUserProfileOperations.cs (1)
  • ReadOldSourceControlCredentials (38-38)
🔇 Additional comments (2)
Ginger/GingerCoreCommon/UserCofig/UserProfile.cs (2)

774-775: Retrieve solution info successfully.

These new lines properly retrieve the relevant GingerSolution object before setting source control properties, ensuring that the logic in the subsequent lines has a valid reference.


848-879: Validate null references and ensure consistent usage.

While retrieving source control properties here, confirm that SourceControlInfo is never null and that the new logic aligns with any calls to RefreshSourceControlCredentials(solutionGuid). Consider adding tests that verify the behavior when GingerSolutionSourceControl.SourceControlInfo might be missing or partially uninitialized.

Comment on lines +778 to +837
if (!string.IsNullOrEmpty(mSourceControl.URL))
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder.Substring(0, mSourceControl.LocalFolder.LastIndexOf('\\'));
GingerSolutionSourceControl.SourceControlInfo.Url = mSourceControl.URL;
}
else
if (!string.IsNullOrEmpty(mSourceControl.Username))
{
GingerSolutionSourceControl.SourceControlInfo.Username = mSourceControl.Username;
}
if (!string.IsNullOrEmpty(mSourceControl.Password))
{
GingerSolutionSourceControl.SourceControlInfo.Password = mSourceControl.Password;
}
if (!string.IsNullOrEmpty(mSourceControl.LocalFolder))
{
if (mSourceControl.LocalFolder.EndsWith(".git"))
{
int slashIndex = mSourceControl.LocalFolder.LastIndexOf('\\');
if (slashIndex >= 0)
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder.Substring(0, slashIndex);
}
else
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
}
}
else
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
}
}
if (!string.IsNullOrEmpty(mSourceControl.Branch))
{
GingerSolutionSourceControl.SourceControlInfo.Branch = mSourceControl.Branch;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorName))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorName = mSourceControl.AuthorName;
}
if (!string.IsNullOrEmpty(mSourceControl.AuthorEmail))
{
GingerSolutionSourceControl.SourceControlInfo.AuthorEmail = mSourceControl.AuthorEmail;
}
if (mSourceControl.Timeout != 0)
{
GingerSolutionSourceControl.SourceControlInfo.LocalFolderPath = mSourceControl.LocalFolder;
GingerSolutionSourceControl.SourceControlInfo.Timeout = mSourceControl.Timeout;
}
GingerSolutionSourceControl.SourceControlInfo.Branch = mSourceControl.Branch;
GingerSolutionSourceControl.SourceControlInfo.AuthorName = mSourceControl.AuthorName;
GingerSolutionSourceControl.SourceControlInfo.AuthorEmail = mSourceControl.AuthorEmail;
GingerSolutionSourceControl.SourceControlInfo.Timeout = mSourceControl.Timeout;
GingerSolutionSourceControl.SourceControlInfo.IsProxyConfigured = mSourceControl.IsProxyConfigured;
GingerSolutionSourceControl.SourceControlInfo.ProxyAddress = mSourceControl.ProxyAddress;
GingerSolutionSourceControl.SourceControlInfo.ProxyPort = mSourceControl.ProxyPort;
if (mSourceControl.IsProxyConfigured)
{
GingerSolutionSourceControl.SourceControlInfo.IsProxyConfigured = mSourceControl.IsProxyConfigured;
}
if (!string.IsNullOrEmpty(mSourceControl.ProxyAddress))
{
GingerSolutionSourceControl.SourceControlInfo.ProxyAddress = mSourceControl.ProxyAddress;
}
if (mSourceControl.ProxyPort != null)
{
GingerSolutionSourceControl.SourceControlInfo.ProxyPort = mSourceControl.ProxyPort;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider encrypting stored credentials and using an OS-agnostic path approach.

  1. The repeated if (!string.IsNullOrEmpty(...)) checks are a safe approach to avoid overwriting valid fields with empty values.
  2. However, assigning mSourceControl.Password directly to SourceControlInfo.Password may risk storing credentials in plain text. Please consider leveraging EncryptedPassword or using a secure store to avoid potential security vulnerabilities.
  3. The .git slash check is Windows-specific and might not handle other OS path separators. Consider using methods like Path.GetDirectoryName or a cross-platform approach to split paths.

@Maheshkale447
Maheshkale447 merged commit 3ea3a6c into Releases/Beta Apr 7, 2025
@Maheshkale447
Maheshkale447 deleted the BugFix/OldDataUsing_Git branch April 7, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants