Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Enzo Cioppettini
ion
Commits
dd2a07f2
Commit
dd2a07f2
authored
5 years ago
by
AdminXVII
Committed by
Michael Aaron Murphy
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove the option wrapper, it does not serve any purpose
parent
af376d75
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/binary/history.rs
+9
-13
9 additions, 13 deletions
src/binary/history.rs
with
9 additions
and
13 deletions
src/binary/history.rs
+
9
−
13
View file @
dd2a07f2
...
...
@@ -18,7 +18,7 @@ pub struct IgnoreSetting {
/// ignore commands that are duplicates
duplicates
:
bool
,
// Yes, a bad heap-based Vec, however unfortunately its not possible to store Regex'es in Array
regexes
:
Option
<
Vec
<
Regex
>
>
,
regexes
:
Vec
<
Regex
>
,
}
/// Contains all history-related functionality for the `Shell`.
...
...
@@ -30,7 +30,6 @@ impl<'a> InteractiveBinary<'a> {
self
.shell
.borrow
()
.variables
()
.get_ref
(
"HISTORY_IGNORE"
)
{
let
mut
settings
=
IgnoreSetting
::
default
();
let
mut
regexes
=
Vec
::
new
();
// for convenience and to avoid typos
let
regex_prefix
=
"regex:"
;
for
pattern
in
patterns
.into_iter
()
{
...
...
@@ -48,13 +47,12 @@ impl<'a> InteractiveBinary<'a> {
let
regex_string
=
&
pattern
[
regex_prefix
.len
()
..
];
// We save the compiled regexes, as compiling them can be an expensive task
if
let
Ok
(
regex
)
=
Regex
::
new
(
regex_string
)
{
regexes
.push
(
regex
);
settings
.
regexes
.push
(
regex
);
}
}
_
=>
continue
,
}
}
settings
.regexes
=
if
!
regexes
.is_empty
()
{
Some
(
regexes
)
}
else
{
None
};
settings
}
else
{
...
...
@@ -113,15 +111,13 @@ impl<'a> InteractiveBinary<'a> {
self
.context
.borrow_mut
()
.history
.remove_duplicates
(
command
);
}
if
let
Some
(
ref
regexes
)
=
ignore
.regexes
{
// ignore command when regex is matched but only if it does not contain
// "HISTORY_IGNORE", otherwise we would also ignore the command which
// sets the variable, which could be annoying.
if
regexes
.iter
()
.any
(|
regex
|
regex
.is_match
(
command
))
&&
!
command
.contains
(
"HISTORY_IGNORE"
)
{
return
false
;
}
// ignore command when regex is matched but only if it does not contain
// "HISTORY_IGNORE", otherwise we would also ignore the command which
// sets the variable, which could be annoying.
if
!
command
.contains
(
"HISTORY_IGNORE"
)
&&
ignore
.regexes
.iter
()
.any
(|
regex
|
regex
.is_match
(
command
))
{
return
false
;
}
// default to true, as it's more likely that we want to save a command in
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment