Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conditionals to script parameters #11342

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SlugFiller
Copy link
Contributor

Proposed changes

  • Add conditional parameters, e.g. {if:SelectedFiles} --files {SelectedFiles}{/if}. The condition is based on whether the parameter is available, e.g. the script was executed from the diff view and any files are selected. Otherwise, the text in between is discarded. Also added {ifnot:option} for the opposite condition/fallback.

Before

No way to condition parameters based on presence or absence.

After

Can use {if:parameterName} to determine of an option is present.

Test methodology

TBD

Test environment(s)

  • Git Extensions 33.33.33
  • Build 43e20df
  • Git 2.42.0.windows.1
  • Microsoft Windows NT 10.0.19045.0
  • .NET 6.0.24
  • DPI 96dpi (no scaling)
  • Portable: False
  • Microsoft.WindowsDesktop.App Versions
    Microsoft.WindowsDesktop.App 6.0.21 [D:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 6.0.24 [D:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned SlugFiller Nov 8, 2023
@SlugFiller
Copy link
Contributor Author

Currently leaving as draft because:

  1. It does not yet account for options that might be provided by a IScriptOptionsProvider but are not. Given that context sensitivity is the main point, having conditions based on the scriptOptionsProvider == null is necessary.
  2. Requires designing and adding tests.

@mstv
Copy link
Member

mstv commented May 12, 2024

(Basically, the replacement of script options works kind of "inverse": If there is a typo or there is no valid replacement, the option is not replaced but provided as is - without any error message.)

This PR will enable users to handle the cases "no blobs (files) exist / are selected" and "no visible control with blobs (files)".

@SlugFiller, are you going to follow up?

@SlugFiller
Copy link
Contributor Author

Ah, I kind of forgot about this in the long wait for the file scripts. And was busy with other stuff. Will try to get back into this soon. And maybe work on the other thing I was planning, which is scripts for remote branches in the left sidebar (currently, they are only available for local branches, and they only isolate by commit, not by exact branch)

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.

None yet

2 participants