CLI progress bar#4132
Conversation
WalkthroughThis pull request updates logging functionality across multiple components by replacing the Boolean flag for overwriting the current log line with a new progress reporting mechanism. The methods in the Reporter and WorkSpaceReporterBase classes now accept a ProgressStatus object, which encapsulates progress message, step, and total steps. A new ProgressStatus class is added, and the CLIHelper has been updated to integrate progress reporting into its workflows. Changes
Possibly related PRs
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 7
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs(5 hunks)Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs(3 hunks)Ginger/GingerCoreCommon/UIElement/ProgressNotifier.cs(1 hunks)Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs(4 hunks)
🔇 Additional comments (5)
Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs (1)
607-610: Reconsider skipping progress updates when progress is 0.The current condition skips progress reporting when
progress == 0, but this might hide valid initial progress updates from the user.- if (progressInformer==null|| progress == 0) + if (progressInformer==null) { return; }Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs (2)
19-19: Good addition of UIElement namespace.The import of the UIElement namespace is properly added to support the new ProgressStatus class.
36-36: Method signature properly updated to use ProgressStatus.The signature change from boolean parameter to ProgressStatus object improves the API by providing a more structured way to report progress.
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (2)
41-41: Method signature properly updated to use ProgressStatus.The signature change from boolean parameter to ProgressStatus object aligns with the changes in WorkSpaceReporterBase.
328-328: Method signature properly updated to use ProgressStatus.The signature change from boolean parameter to ProgressStatus object improves the API consistency with the rest of the application.
There was a problem hiding this comment.
Actionable comments posted: 6
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs(5 hunks)Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs(3 hunks)Ginger/GingerCoreCommon/UIElement/ProgressNotifier.cs(2 hunks)Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs(4 hunks)Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs (1)
Learnt from: GokulBothe99
PR: Ginger-Automation/Ginger#4085
File: Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs:317-317
Timestamp: 2025-02-06T07:15:58.225Z
Learning: In GITSourceControl class, the progressNotifier parameter can be null - in such cases the progress reporting is simply skipped without any issues as null checks are properly implemented in the code.
🔇 Additional comments (12)
Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs (1)
1439-1439: Reset the field when starting new operations.
previousPercentagealways starts at 0. If this same instance is reused for multiple downloads or fetch operations, consider re-initializing it to 0 before each new operation to prevent leftover state issues.Ginger/GingerCoreCommon/UIElement/ProgressNotifier.cs (1)
26-26: Parameter tuple enhances clarity.Exposing the progress parameters as a tuple in
StatusUpdateHandleris a clean approach. Ensure that each subscriber handles them correctly to avoid confusion about which value is which.Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs (3)
82-82: Adding a dedicatedProgressStatusfield.Introducing
progressStatusat the class level is helpful. Confirm that it’s appropriately reset to avoid stale data when reusing the same instance ofCLIHelper.
569-571: Wire up event and instantiateprogressStatus.Attaching
StatusUpdateHandlerhere ensures theProgressNotifier_ProgressUpdatedis invoked. This is good practice for centralized logic. Confirm that detachment infinallyconsistently happens in all code paths.
588-588: NullifyprogressStatusafter operation.Clearing
progressStatusis a good cleanup step. Ensure no other references to it exist or rely on it after this point.Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (3)
24-24: New import forProgressStatus.The added
using Amdocs.Ginger.Common.UIElement;is needed to reference theProgressStatusclass. This is correct and keeps the file self-contained.
41-58: Potentially skip standard logging whenprogressInformeris not null.You only call
WorkSpaceReporter.ToLogifprogressInformeris null. If the intent is to fully replace standard logs when progress is reported, that’s fine. Otherwise, consider logging both a summary and the progress updates.
327-341: RefactoredToConsoleto acceptProgressStatus.Allowing console output to reflect progress details is valuable. This change is consistent with the new progress-based logging approach.
Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs (4)
19-19: No immediate concerns identified.
Thisusing Amdocs.Ginger.Common.UIElement;import might be necessary for features not shown in the snippet.
39-39: Looks good!
Using string interpolation for the log header is clean and readable.
75-78: Progress bar skipping when output is redirected is reasonable.
This logic avoids cluttering logs with partial progress updates in redirected output scenarios.
36-37:Details
✅ Verification successful
Ensure references to the updated method signature are correct.
The signature now acceptsProgressStatus progressStatusinstead ofbool overwriteCurrentLine. Please verify that all calls toToConsolethroughout the codebase have been updated accordingly to avoid breakage.You can run a repository-wide search for
ToConsole(to confirm all usage sites are updated:
🏁 Script executed:
#!/bin/bash # Searching for references to the updated ToConsole method rg -A 2 -B 2 "ToConsole\("Length of output: 10697
Usage of Updated
ToConsoleSignature VerifiedThe repository-wide search confirms that all calls to
ToConsolenow correctly use the updated method signature that accepts aProgressStatus progressStatusparameter (defaulting to null). In particular:
- In
GingerCoreCommon/ReporterLib/Reporter.cs, calls include the new parameter either through an explicit named argument (e.g.,progressStatus: progressInformer) or rely on the default value.- In
GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs, the method signature is updated as expected.- No residual calls passing a
bool overwriteCurrentLineare found.No further modifications are needed.
Maheshkale447
left a comment
There was a problem hiding this comment.
Change the base branch to master
The base branch was changed.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs(3 hunks)
🔇 Additional comments (1)
Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs (1)
1468-1471: Consistent progress update threshold applied.The same threshold check has been implemented consistently in this method.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs(3 hunks)
🔇 Additional comments (6)
Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs (6)
1398-1401: Progress reporting optimization implemented correctly.Adding a threshold check for percentage changes avoids redundant notifications when progress hasn't changed significantly, improving UI responsiveness.
1404-1405: Progress tracking implementation looks good.Updating the previousPercentage after notification ensures accurate tracking of the last reported value.
1440-1440: Consider using local variables instead of class fields for progress tracking.Using a class-level field for
previousPercentagecould lead to issues if multiple Git operations run concurrently, as they would all share and modify the same variable.- private double previousPercentage = 0; + // Remove field and use local variables in each method insteadThen, in the appropriate methods (GetProjectWithProgress and GetFetchOptionsWithProgress), add a local variable:
+ double previousPercentage = 0;This change avoids potential race conditions and keeps progress tracking isolated to each operation.
1462-1462: Remove unnecessary blank line.This blank line doesn't serve any purpose and can be removed for better code consistency.
-
1469-1472: Consistent threshold check implementation.The same optimization pattern is correctly applied here, maintaining consistency across similar operations.
1475-1476: Progress tracking update is properly implemented.Storing the current percentage ensures we only report meaningful changes in future iterations.
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit