Skip to content

Conversation

@andreihrybo
Copy link
Contributor

@andreihrybo andreihrybo commented Nov 11, 2025

Add a 'get list' function for gCTS objects and create tests for it.
Add context manager for buffer repository config
Add flags --no-import and --buffer-only to the clone and checkout gCTS operations, and refactor these operations.

If the flags --no-import or were passed to the gcts clone or checkout command, we don’t look at the activity — we just check whether the repository was cloned and whether the branch matches in loop {--wait-for-ready} seconds.

If we use asynchronous cloning with a Task and the --no-import flag, then after the task is completed we only check once that the repository has been cloned by verifying its status, since the task has already been processed during the {--wait-for-ready} seconds.

flag --buffer-only allow us to check activities


VCS_NO_IMPORT - No objects are imported or added to the buffer during an update or clone action.
VCS_BUFFER_ONLY - No objects are imported into the system, but a transport request is generated and added to the buffer. You can manually import the transport request at a later point in time.

@jfilak
Copy link
Owner

jfilak commented Nov 14, 2025

Nice! I really appreciate your refactoring efforts to make the code look nice and follow the Zen of Python.

@jfilak
Copy link
Owner

jfilak commented Nov 19, 2025

Can you please "rebase" your branch on the latest master instead of merging master into your PR branch? It makes review much more convenient.

@jfilak
Copy link
Owner

jfilak commented Nov 19, 2025

Also, don't be afraid of force pushing your PR branch. For example the "Revert" commits are not useful for review at all. Look at how "git rebase -i ..." works and reorganize and squash your commits please.

@andreihrybo andreihrybo force-pushed the gcts-update-operations branch from a2ea858 to 66a942b Compare November 19, 2025 10:02
@andreihrybo andreihrybo force-pushed the gcts-update-operations branch from 66a942b to 9800ba5 Compare November 19, 2025 10:24
@andreihrybo andreihrybo reopened this Nov 19, 2025
sap/cli/gcts.py Outdated
response = sap.rest.gcts.simple.checkout(
connection, args.branch, repo=repo,
no_import=args.no_import, buffer_only=args.buffer_only,
progress_consumer=LogSugarOperationProgress())
Copy link
Owner

Choose a reason for hiding this comment

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

The command line interface which is directly communicating with users should use ConsoleSugarOperationProgress.

sap/cli/gcts.py Outdated
}
if args.sync_clone:
clone_action = sap.rest.gcts.simple.clone
parameters['progress_consumer'] = LogSugarOperationProgress() if args.buffer_only or args.no_import else None
Copy link
Owner

Choose a reason for hiding this comment

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

The command line interface which is directly communicating with users should use ConsoleSugarOperationProgress.

Copy link
Contributor Author

@andreihrybo andreihrybo Nov 20, 2025

Choose a reason for hiding this comment

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

It seems that TaskOperationProgress also should use console.printout() without _mod_log().info().

Copy link
Owner

Choose a reason for hiding this comment

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

My initial idea was the following:

  • have a default simple implementation using logger for "library" usecases
  • create a special type for command line interfaces (usint console)
  • also be able to have a special type for Ansible which should not print anything but shall collect messages and report them in the json output

Since you have the clear picture of your changes in mind, please adapt it accordingly to the points above.

abap_modifications_disabled(repo, progress_consumer) if no_import else context_stub(),
buffer_only_enabled(repo, progress_consumer) if buffer_only else context_stub()
):
repo.clone()
Copy link
Owner

Choose a reason for hiding this comment

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

The context managers are supposed to temporarily modify repository configuration. In the case of a network error or something like that, the code execution is interrupted and the configuration changes will become persistent. To avoid user confusion, the program should let the end user know how to revert the configuration changes. Look at the example at: https://github.com/jfilak/sapcli/blob/master/sap/cli/gcts.py#L968

Copy link
Owner

Choose a reason for hiding this comment

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

You may need to update the class SugarOperationProgress because you cannot use the construction:

 if checkout_progress.recover_message:
            console.printerr(checkout_progress.recover_message)

Since the file sap/rest/gcts/simple.py must not use console directly beucase the simple functions can be called from:

  • command line interface
  • other tools witout standard output
  • ansible

return repo
with (
abap_modifications_disabled(repo, progress_consumer) if no_import else context_stub(),
buffer_only_enabled(repo, progress_consumer) if buffer_only else context_stub()
Copy link
Owner

Choose a reason for hiding this comment

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

The context managers are supposed to temporarily modify repository configuration. In the case of a network error or something like that, the code execution is interrupted and the configuration changes will become persistent. To avoid user confusion, the program should let the end user know how to revert the configuration changes. Look at the example at: https://github.com/jfilak/sapcli/blob/master/sap/cli/gcts.py#L968

return repo.checkout(branch)
with (
abap_modifications_disabled(repo, progress_consumer) if no_import else context_stub(),
buffer_only_enabled(repo, progress_consumer) if buffer_only else context_stub()
Copy link
Owner

Choose a reason for hiding this comment

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

The context managers are supposed to temporarily modify repository configuration. In the case of a network error or something like that, the code execution is interrupted and the configuration changes will become persistent. To avoid user confusion, the program should let the end user know how to revert the configuration changes. Look at the example at: https://github.com/jfilak/sapcli/blob/master/sap/cli/gcts.py#L968

@andreihrybo andreihrybo reopened this Nov 28, 2025
@jfilak jfilak merged commit 80594de into jfilak:master Dec 1, 2025
2 checks passed
@jfilak
Copy link
Owner

jfilak commented Dec 1, 2025

Well done! Thank you.

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