Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ RepoM uses plugins to extend functionality. At this moment, when a plugin is ava
- [LuceneQueryParser](docs/RepoM.Plugin.LuceneQueryParser.md)
- [SonarCloud](docs/RepoM.Plugin.SonarCloud.md)
- [Statistics](docs/RepoM.Plugin.Statistics.md)
- [WebBrowser](docs/RepoM.Plugin.WebBrowser.md)
- [WindowsExplorerGitInfo](docs/RepoM.Plugin.WindowsExplorerGitInfo.md)

2 changes: 2 additions & 0 deletions README.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ RepoM uses plugins to extend functionality. At this moment, when a plugin is ava
- [LuceneQueryParser](docs/RepoM.Plugin.LuceneQueryParser.md)
- [SonarCloud](docs/RepoM.Plugin.SonarCloud.md)
- [Statistics](docs/RepoM.Plugin.Statistics.md)
- [WebBrowser](docs/RepoM.Plugin.WebBrowser.md)
- [WindowsExplorerGitInfo](docs/RepoM.Plugin.WindowsExplorerGitInfo.md)

46 changes: 46 additions & 0 deletions RepoM.sln
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RepoM.App.Tests", "tests\Re
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RepoM.Plugin.Misc.Tests", "tests\RepoM.Plugin.Misc.Tests\RepoM.Plugin.Misc.Tests.csproj", "{A2264CB6-39DE-4EA2-8C1D-BA28115351E7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RepoM.Plugin.WebBrowser", "src\RepoM.Plugin.WebBrowser\RepoM.Plugin.WebBrowser.csproj", "{23D796D1-1902-4357-9C95-4FB120A24A6E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RepoM.Plugin.WebBrowser.Tests", "tests\RepoM.Plugin.WebBrowser.Tests\RepoM.Plugin.WebBrowser.Tests.csproj", "{E976587E-F48E-4647-A307-91EFEC8F571C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -525,6 +529,46 @@ Global
{A2264CB6-39DE-4EA2-8C1D-BA28115351E7}.Release|x64.Build.0 = Release|Any CPU
{A2264CB6-39DE-4EA2-8C1D-BA28115351E7}.Release|x86.ActiveCfg = Release|Any CPU
{A2264CB6-39DE-4EA2-8C1D-BA28115351E7}.Release|x86.Build.0 = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|ARM.Build.0 = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|ARM64.Build.0 = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|x64.ActiveCfg = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|x64.Build.0 = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|x86.ActiveCfg = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Debug|x86.Build.0 = Debug|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|Any CPU.Build.0 = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|ARM.ActiveCfg = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|ARM.Build.0 = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|ARM64.ActiveCfg = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|ARM64.Build.0 = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|x64.ActiveCfg = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|x64.Build.0 = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|x86.ActiveCfg = Release|Any CPU
{23D796D1-1902-4357-9C95-4FB120A24A6E}.Release|x86.Build.0 = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|ARM.ActiveCfg = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|ARM.Build.0 = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|ARM64.Build.0 = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|x64.ActiveCfg = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|x64.Build.0 = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|x86.ActiveCfg = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Debug|x86.Build.0 = Debug|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|Any CPU.Build.0 = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|ARM.ActiveCfg = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|ARM.Build.0 = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|ARM64.ActiveCfg = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|ARM64.Build.0 = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|x64.ActiveCfg = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|x64.Build.0 = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|x86.ActiveCfg = Release|Any CPU
{E976587E-F48E-4647-A307-91EFEC8F571C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -547,6 +591,8 @@ Global
{ED155806-81AD-49CC-B150-2C17F4902A1D} = {D6E372DC-10D3-4997-9DFC-568B4666635A}
{85BA3DD7-8589-4020-A7DF-7E9F5D1A9C1A} = {D6E372DC-10D3-4997-9DFC-568B4666635A}
{A2264CB6-39DE-4EA2-8C1D-BA28115351E7} = {D6E372DC-10D3-4997-9DFC-568B4666635A}
{23D796D1-1902-4357-9C95-4FB120A24A6E} = {D6E372DC-10D3-4997-9DFC-568B4666635A}
{E976587E-F48E-4647-A307-91EFEC8F571C} = {D6E372DC-10D3-4997-9DFC-568B4666635A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1765ABAA-0652-4DA5-ABBF-05396F2957D7}
Expand Down
39 changes: 7 additions & 32 deletions docs/ActionList.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,6 @@ repository-actions:
<sup><a href='/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/DocumentationFiles/BrowseRepository01.testfile.yaml#L3-L13' title='Snippet source file'>snippet source</a> | <a href='#snippet-repositoryactionsbrowserepository01' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## browser@1

Action opening a webbrowser with the provided url.<!-- include: DocsRepositoryActionsTests.DocsRepositoryActionsSettings_RepositoryActionBrowserV1.verified.md -->

Action specific properties:

- `url`: The url to browse to. (required, evaluated, string)<!-- endInclude -->

Example:

<!-- snippet: RepositoryActionsBrowser01 -->
<a id='snippet-repositoryactionsbrowser01'></a>
```yaml
repository-actions:
actions:
- type: browser@1
active: true
variables: []
name: 'My Github'
url: 'https://github.com/coenm'

- type: browser@1
name: 'My Github'
url: 'https://github.com/coenm'
```
<sup><a href='/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/DocumentationFiles/Browser01.testfile.yaml#L3-L17' title='Snippet source file'>snippet source</a> | <a href='#snippet-repositoryactionsbrowser01' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## command@1

Action to excute a command (related the the repository)<!-- include: DocsRepositoryActionsTests.DocsRepositoryActionsSettings_RepositoryActionCommandV1.verified.md -->
Expand Down Expand Up @@ -276,11 +248,10 @@ repository-actions:
variable: environment
skip: ''
actions:
- type: browser@1
name: '{var.environment.key}'
url: '{var.environment.url}'
- type: just-text@1
name: '{var.environment.key} - {var.environment.url}'
```
<sup><a href='/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/DocumentationFiles/Foreach01.testfile.yaml#L3-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-repositoryactionsforeach01' title='Start of snippet'>anchor</a></sup>
<sup><a href='/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/DocumentationFiles/Foreach01.testfile.yaml#L3-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-repositoryactionsforeach01' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## git-checkout@1
Expand Down Expand Up @@ -652,6 +623,10 @@ repository-actions:

See the [Heidi](RepoM.Plugin.Heidi.md) plugin for more information.

include _plugins.webbrowser.action

See the [WebBrowser](RepoM.Plugin.WebBrowser.md) plugin for more information.

# Repository Actions

These actions are part of the Repository Actions config file described in [Repository Actions](RepositoryActions.md).
85 changes: 85 additions & 0 deletions docs/RepoM.Plugin.WebBrowser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# WebBrowser

The WebBrowser module provides a repository action to open an URL in a given webbrowser.

To use this module, make sure it is enabled in RepoM by opening the menu and navigate to 'Plugins'. When enabling or disabling a plugin, you should restart RepoM.<!-- singleLineInclude: _plugin_enable. path: /docs/mdsource/_plugin_enable.include.md -->

## Configuration<!-- include: DocsModuleSettingsTests.DocsModuleSettings_WebBrowserPackage#desc.verified.md -->

This plugin has specific configuration stored in a separate configuration file stored in `%APPDATA%/RepoM/Module/` directory. This configuration file should be edit manually. The safest way to do this is, is when RepoM is not running.

The following default configuration is used:

```json
{
"Version": 1,
"Settings": {
"Browsers": null,
"Profiles": null
}
}
```

For example:

```json
{
"Version": 1,
"Settings": {
"Browsers": {
"Edge": "C:\\PathTo\\msedge.exe",
"FireFox": "C:\\PathTo\\Mozilla\\firefox.exe"
},
"Profiles": {
"Work": {
"BrowserName": "Edge",
"CommandLineArguments": "\"--profile-directory=Profile 4\" {url}"
},
"Incognito": {
"BrowserName": "Edge",
"CommandLineArguments": "-inprivate"
},
"Incognito2": {
"BrowserName": "FireFox",
"CommandLineArguments": "-inprivate {url}"
}
}
}
}
```

Properties:

- `Browsers`: Dictionary of known browsers and their path to use for opening urls.
- `Profiles`: Profiles to use. <!-- endInclude -->

## browser@1<!-- include: _plugins.webbrowser.action. path: /docs/mdsource/_plugins.webbrowser.action.include.md -->

Action opening a webbrowser with the provided url.<!-- include: DocsRepositoryActionsTests.DocsRepositoryActionsSettings_RepositoryActionBrowserV1.verified.md -->

Action specific properties:

- `url`: The url to browse to. (required, evaluated, string)
- `profile`: profile name used to select browser and browser profile (optional, evaluated, string)<!-- endInclude -->

Example:

<!-- snippet: RepositoryActionsBrowser01 -->
<a id='snippet-repositoryactionsbrowser01'></a>
```yaml
repository-actions:
actions:
- type: browser@1
active: true
variables: []
name: My Github
url: https://github.com/coenm

- type: browser@1
name: My Github
url: https://github.com/coenm
profile: edge
```
<sup><a href='/tests/RepoM.Plugin.WebBrowser.Tests/DocumentationFiles/Browser01.testfile.yaml#L3-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-repositoryactionsbrowser01' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
<!-- endInclude -->
12 changes: 4 additions & 8 deletions docs/mdsource/ActionList.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ Example:

snippet: RepositoryActionsBrowseRepository01

## browser@1

include: DocsRepositoryActionsTests.DocsRepositoryActionsSettings_RepositoryActionBrowserV1.verified.md

Example:

snippet: RepositoryActionsBrowser01

## command@1

include: DocsRepositoryActionsTests.DocsRepositoryActionsSettings_RepositoryActionCommandV1.verified.md
Expand Down Expand Up @@ -150,6 +142,10 @@ include: _plugins.heidi.action

See the [Heidi](RepoM.Plugin.Heidi.md) plugin for more information.

include _plugins.webbrowser.action

See the [WebBrowser](RepoM.Plugin.WebBrowser.md) plugin for more information.

# Repository Actions

These actions are part of the Repository Actions config file described in [Repository Actions](RepositoryActions.md).
9 changes: 9 additions & 0 deletions docs/mdsource/RepoM.Plugin.WebBrowser.source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# WebBrowser

The WebBrowser module provides a repository action to open an URL in a given webbrowser.

include: _plugin_enable

include: DocsModuleSettingsTests.DocsModuleSettings_WebBrowserPackage#desc.verified.md

include: _plugins.webbrowser.action
7 changes: 7 additions & 0 deletions docs/mdsource/_plugins.webbrowser.action.include.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## browser@1

include: DocsRepositoryActionsTests.DocsRepositoryActionsSettings_RepositoryActionBrowserV1.verified.md

Example:

snippet: RepositoryActionsBrowser01
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider;
using DotNetEnv;
using Microsoft.Extensions.Logging;
using RepoM.Api.Common;
using RepoM.Api.Git;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Deserialization;
Expand Down Expand Up @@ -93,7 +92,7 @@ private string GetRepositoryActionsFilename(string basePath)
var tags = new List<TagsCollection>();

// load default file
RepositoryActionConfiguration? rootFile = null;
RepositoryActionConfiguration? rootFile;
RepositoryActionConfiguration? repoSpecificConfig = null;

var filename = GetRepositoryActionsFilename(_appDataPathProvider.AppDataPath);
Expand Down Expand Up @@ -273,21 +272,24 @@ private bool IsEnabled(string? booleanExpression, bool defaultWhenNullOrEmpty, I
{
return string.IsNullOrWhiteSpace(booleanExpression)
? defaultWhenNullOrEmpty
: _repoExpressionEvaluator.EvaluateBooleanExpression(booleanExpression!, repository);
: _repoExpressionEvaluator.EvaluateBooleanExpression(booleanExpression, repository);
}
}

public class RepositoryTagsConfigurationFactory : IRepositoryTagsFactory
{
private readonly IRepositoryExpressionEvaluator _repoExpressionEvaluator;
private readonly RepositoryConfigurationReader _repoConfigReader;
private readonly ILogger _logger;

public RepositoryTagsConfigurationFactory(
IRepositoryExpressionEvaluator repoExpressionEvaluator,
RepositoryConfigurationReader repoConfigReader)
RepositoryConfigurationReader repoConfigReader,
ILogger logger)
{
_repoExpressionEvaluator = repoExpressionEvaluator ?? throw new ArgumentNullException(nameof(repoExpressionEvaluator));
_repoConfigReader = repoConfigReader ?? throw new ArgumentNullException(nameof(repoConfigReader));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public IEnumerable<string> GetTags(Repository repository)
Expand All @@ -297,23 +299,6 @@ public IEnumerable<string> GetTags(Repository repository)

private IEnumerable<string> GetTagsInner(IRepository repository)
{
List<EvaluatedVariable> EvaluateVariables(IEnumerable<Variable>? vars)
{
if (vars == null)
{
return new List<EvaluatedVariable>(0);
}

return vars
.Where(v => IsEnabled(v.Enabled, true, repository))
.Select(v => new EvaluatedVariable
{
Name = v.Name,
Value = Evaluate(v.Value, repository),
})
.ToList();
}

Dictionary<string, string>? repositoryEnvVars;
List<EvaluatedVariable>? variables;
List<TagsCollection>? tags;
Expand All @@ -322,18 +307,18 @@ List<EvaluatedVariable> EvaluateVariables(IEnumerable<Variable>? vars)
{
(repositoryEnvVars, variables, _, tags) = _repoConfigReader.Get(repository);
}
catch (Exception)
catch (Exception e)
{
// todo, log
yield break;
_logger.LogError(e, "Could not get the configuration for repository {repository} {message}.", repository.Name, e.Message);
yield break;
}

using IDisposable d1 = RepoMVariableProviderStore.Push(variables ?? new List<EvaluatedVariable>(0));
using IDisposable d2 = EnvironmentVariableStore.Set(repositoryEnvVars);

foreach (TagsCollection tagsCollection in ((IEnumerable<TagsCollection>?)tags) ?? Array.Empty<TagsCollection>())
{
using IDisposable d3 = RepoMVariableProviderStore.Push(EvaluateVariables(tagsCollection.Variables));
using IDisposable d3 = RepoMVariableProviderStore.Push(EvaluateVariables(tagsCollection.Variables, repository));

foreach (RepositoryActionTag action in tagsCollection.Tags)
{
Expand All @@ -350,6 +335,23 @@ List<EvaluatedVariable> EvaluateVariables(IEnumerable<Variable>? vars)
}
}

private List<EvaluatedVariable> EvaluateVariables(IEnumerable<Variable>? vars, IRepository repository)
{
if (vars == null)
{
return new List<EvaluatedVariable>(0);
}

return vars
.Where(v => IsEnabled(v.Enabled, true, repository))
.Select(v => new EvaluatedVariable
{
Name = v.Name,
Value = Evaluate(v.Value, repository),
})
.ToList();
}

private object? Evaluate(object? input, IRepository repository)
{
if (input is string s)
Expand Down
1 change: 0 additions & 1 deletion src/RepoM.Api/IO/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public static void StartProcess(string process, string arguments)
{
try
{
Debug.WriteLine("Starting: " + process + arguments);
Process.Start(process, arguments);
return;
}
Expand Down
Loading