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

simplify install #1830

Merged
merged 5 commits into from
Feb 6, 2021
Merged

simplify install #1830

merged 5 commits into from
Feb 6, 2021

Conversation

NoahGorny
Copy link
Member

@NoahGorny NoahGorny commented Feb 5, 2021

  • install: Move modify config check into separate function
  • install: Move backup check into a separate function
  • install: Add --overwrite-backup flag

Description

Cleans up the config backup logic and split it into smaller functions.
Also add a new flag which allows us to overwrite backups silently (previously we did not check for existing backups in silent installations). This does change the default behaviour, so I am open to a debate on that.

Motivation and Context

#1829 prompted me to take a look- and I indeed saw a problem. I refactored the code a bit in order to fix this.
Closes #1829

How Has This Been Tested?

Locally, tested various flags and combinations, with and without backup. Works as expected.
As I said, now silent installations fail if a backup is already present, unless "-f/--overwrite-backup" is specified

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

Noah Gorny added 3 commits February 6, 2021 00:15
This helps us make the logic easier to read, and remove unneeded
confusion.
This will ensure users will specify whether they want to overwrite the
backup or not, and check it even when we do silent installation
This does change the default behaviour and exits if the -f flag is not
specified and a backup is present.
@kirkmadera
Copy link

This fix looks like it should fix the issue

install.sh Outdated
@@ -76,6 +77,69 @@ function backup_append() {
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
}

function check_for_backup() {
if ! [ -e "$HOME/$BACKUP_FILE" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

double bracket test are technically safer. if we're writing or transposing new things, I'd like to push to switch

Copy link
Member Author

Choose a reason for hiding this comment

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

done

install.sh Outdated
@@ -76,6 +77,69 @@ function backup_append() {
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
}

function check_for_backup() {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not going to road block since this in the install script, but it'd be nice to start making all functions be prefixed with _bash-it or something consistent and namespaced.

Copy link
Member Author

Choose a reason for hiding this comment

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

added this prefix to all functions in install.sh

Copy link
Member

@cornfeedhobo cornfeedhobo left a comment

Choose a reason for hiding this comment

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

@NoahGorny This is the first time I've really looked at this file in detail. I can see some places we'll want to improve in the future, but this is a great fix + cleanup. Thanks for this!

@NoahGorny NoahGorny merged commit db318cd into Bash-it:master Feb 6, 2021
@NoahGorny NoahGorny deleted the simplify-install branch February 6, 2021 20:57
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.

append-to-config option does not run unless --silent flag is passed
3 participants