Skip to content

CLI progress bar#4132

Merged
Maheshkale447 merged 4 commits into
masterfrom
BugFix/CLIGitProgress
Mar 4, 2025
Merged

CLI progress bar#4132
Maheshkale447 merged 4 commits into
masterfrom
BugFix/CLIGitProgress

Conversation

@GokulBothe99

@GokulBothe99 GokulBothe99 commented Feb 28, 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
    • Introduced a progress reporting mechanism that displays real-time task status.
  • Refactor
    • Enhanced logging and console outputs to provide structured progress feedback.
    • Improved CLI notifications for clearer, more accurate progress updates during operations.
    • Simplified progress update logic to reduce redundant notifications.
    • Added a new structure for encapsulating progress-related data.

@coderabbitai

coderabbitai Bot commented Feb 28, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This 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

File(s) Change Summary
Ginger/.../ReporterLib/Reporter.cs
Ginger/.../ReporterLib/WorkSpaceReporterBase.cs
Updated ToLog and ToConsole method signatures by replacing Boolean overwriteCurrentLine with ProgressStatus progressInformer. Internal logic adjusted to check for a progress object instead of a Boolean flag and output progress bars when provided.
Ginger/.../UIElement/ProgressNotifier.cs Added a new public class ProgressStatus with fields: ProgressMessage (string), ProgressStep (int), and TotalSteps (int) to encapsulate progress information.
Ginger/.../CLILib/CLIHelper.cs Introduced a progressStatus member in the DownloadSolutionFromSourceControl method and updated progress update logic to utilize the new ProgressStatus mechanism.
Ginger/.../SourceControl/GITSourceControl.cs Added a previousPercentage variable to track progress percentage during file downloads in GetProjectWithProgress and GetFetchOptionsWithProgress methods, enhancing progress notification management.

Possibly related PRs

  • Ginger play console issue #4110: The changes in the main PR and the retrieved PR are related as both modify the ToConsole method in the WorkSpaceReporterBase class, specifically altering the handling of the overwriteCurrentLine parameter and its associated logic.
  • Shared repository Variable duplicate fix, Re run Failed fix and Edge … #3976: The changes in the main PR are related to the modifications in the ToConsole method in both Reporter.cs and WorkSpaceReporterBase.cs, which involve replacing the overwriteCurrentLine parameter with a ProgressStatus parameter, indicating a direct connection in functionality.
  • showing progress on UI #4127: The changes in the main PR are related to the modifications in the ToConsole method's signature in both the Reporter and WorkSpaceReporterBase classes, which now utilize the ProgressStatus parameter, similar to the updates in the GITSourceControl class's methods that also incorporate progress reporting.

Poem

I'm a bunny with a coding flair,
Hopping through progress updates with care.
Logging now sings with a progress beat,
Each step and message perfectly neat.
Carrots and code in joyful array—
A rabbit's cheer for changes today!

✨ Finishing Touches
  • 📝 Generate Docstrings

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?

❤️ Share
🪧 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 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.

@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: 7

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bce6ba7 and bbbbe24.

📒 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.

Comment thread Ginger/GingerCoreCommon/UIElement/ProgressNotifier.cs
Comment thread Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs Outdated
Comment thread Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs Outdated
Comment thread Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs Outdated
Comment thread Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs
Comment thread Ginger/GingerCoreCommon/ReporterLib/Reporter.cs
Comment thread Ginger/GingerCoreCommon/ReporterLib/Reporter.cs Outdated

@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: 6

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bbbbe24 and f7b3a0a.

📒 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.

previousPercentage always 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 StatusUpdateHandler is 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 dedicated ProgressStatus field.

Introducing progressStatus at the class level is helpful. Confirm that it’s appropriately reset to avoid stale data when reusing the same instance of CLIHelper.


569-571: Wire up event and instantiate progressStatus.

Attaching StatusUpdateHandler here ensures the ProgressNotifier_ProgressUpdated is invoked. This is good practice for centralized logic. Confirm that detachment in finally consistently happens in all code paths.


588-588: Nullify progressStatus after operation.

Clearing progressStatus is 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 for ProgressStatus.

The added using Amdocs.Ginger.Common.UIElement; is needed to reference the ProgressStatus class. This is correct and keeps the file self-contained.


41-58: Potentially skip standard logging when progressInformer is not null.

You only call WorkSpaceReporter.ToLog if progressInformer is 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: Refactored ToConsole to accept ProgressStatus.

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.
This using 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 accepts ProgressStatus progressStatus instead of bool overwriteCurrentLine. Please verify that all calls to ToConsole throughout 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 ToConsole Signature Verified

The repository-wide search confirms that all calls to ToConsole now correctly use the updated method signature that accepts a ProgressStatus progressStatus parameter (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 overwriteCurrentLine are found.

No further modifications are needed.

Comment thread Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs
Comment thread Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs Outdated
Comment thread Ginger/GingerCoreCommon/UIElement/ProgressNotifier.cs
Comment thread Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs
Comment thread Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs
Comment thread Ginger/GingerCoreCommon/ReporterLib/WorkSpaceReporterBase.cs

@Maheshkale447 Maheshkale447 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.

Change the base branch to master

coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 4, 2025
@GokulBothe99
GokulBothe99 changed the base branch from Releases/Official-Release to master March 4, 2025 05:05
@GokulBothe99
GokulBothe99 dismissed coderabbitai[bot]’s stale review March 4, 2025 05:05

The base branch was changed.

@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 f7b3a0a and d66fd01.

📒 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.

Comment thread Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs
Comment thread Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs
Comment thread Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs
@Maheshkale447
Maheshkale447 enabled auto-merge March 4, 2025 06:38

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d66fd01 and b5b8f07.

📒 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 previousPercentage could 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 instead

Then, 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.

Comment thread Ginger/GingerCoreNET/SourceControl/GITSourceControl.cs
@Maheshkale447
Maheshkale447 merged commit 1e7dbaf into master Mar 4, 2025
@Maheshkale447
Maheshkale447 deleted the BugFix/CLIGitProgress branch March 4, 2025 17:16
@coderabbitai coderabbitai Bot mentioned this pull request Jul 14, 2025
15 tasks
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