Skip to content

Commit

Permalink
Migrate master to main (#228)
Browse files Browse the repository at this point in the history
* Migrate master to main

* Apply linter

---------

Co-authored-by: Gabriel Trabanco Llano <gtrabanco@users.noreply.github.com>
  • Loading branch information
gtrabanco and gtrabanco authored Jun 28, 2024
1 parent 1e6e52d commit f03d70a
Show file tree
Hide file tree
Showing 13 changed files with 324 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ See [`support.md`][support] on how to get help.
it’s your job to convince us
* Two small PRs are prefered than one big PR
* Separate issues from features in a PR, if you need to fix an issue to develop a feature or you find an issue when developing a feature. Make a `fix` branch, solve the issue, make the PR in the repository. Apply the patch by cherry-pick or by merging in the `feature` branch. Show in the description that PR ## is included in this feature.
* Merge master is preferred in PR if there is any update. We prefer that you solve the possible merge conflicts.
* Merge main is preferred in PR if there is any update. We prefer that you solve the possible merge conflicts.

## Resources

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: CI
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
paths-ignore:
- 'dotfiles_template/*.md'
- 'docs/**'
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This need a very big improvement
-->

* Can be installed as standalone, not mandatory to be as git submodule (Should be done manually).
* Init scripts ([see init-scripts](https://github.com/gtrabanco/dotfiles/tree/master/shell/init.scripts) in [gtrabanco/dotfiles](https://github.com/gtrabanco/dotfiles)). This provides many possibilities as modular loading of custom variables or aliases by machine, loading secrets... Whatever you can imagine.
* Init scripts ([see init-scripts](https://github.com/gtrabanco/dotfiles/tree/main/shell/init.scripts) in [gtrabanco/dotfiles](https://github.com/gtrabanco/dotfiles)). This provides many possibilities as modular loading of custom variables or aliases by machine, loading secrets... Whatever you can imagine.
* Per machine (or whatever name you want to) export packages `sloth packages dump` (you can use `dot` instead of `sloth`, we also have aliases for this command like `lazy` and `s`).
* Compatibility with all Dotly scripts.
* When you install SLOTH a backup of all previous files is done (`.bashrc`, `.zshrc` and `.zshenv`) if you request it.
Expand All @@ -62,7 +62,7 @@ This need a very big improvement
* Improved package managers and the way they are executed. You can also create your own wrappers for your package manager.
* Improved registry (recipes) and how recipes can be updated as if they were packages.

**About autocompletion** Is a known issue that current autocompletion for `dot` command does not work as good as supposed and currently only autocomplete the first argument (option). This will be fixed in the future but suppossed a gain in complexity for autocompletion that I am not interested in develop now. [See PR #146 for more information](https://github.com/gtrabanco/.Sloth/pull/146)
**About autocompletion** Is a known issue that current autocompletion for `dot` command does not work as good as supposed and currently only autocomplete the first argument (option). This will be fixed in the future but suppossed a gain in complexity for autocompletion that I am not interested in develop now. [See PR #146 for more information](https://github.com/gtrabanco/dotSloth/pull/146)

## INSTALLATION

Expand Down Expand Up @@ -130,7 +130,7 @@ dotfiles
git remote add origin git@github.com:${GITHUB_USER}/${GITHUB_DOTFILES_REPOSITORY}.git
git add .
git commit -m "Initial commit"
git push origin master
git push origin main
```
Replace the variables for your own values or the full url for your repository.

Expand Down Expand Up @@ -211,7 +211,7 @@ There is a recipe for NVM and NVM and default LTS node, npm & npx are installed

# Contributing

You can contribute to the project by making a PR, reporting an issue, suggesting a feature, writting about the project or by applying any idea you have. All contributions that respect our [Code of Conduct](https://github.com/gtrabanco/.Sloth/blob/master/.github/code-of-conduct.md) are very welcoming.
You can contribute to the project by making a PR, reporting an issue, suggesting a feature, writting about the project or by applying any idea you have. All contributions that respect our [Code of Conduct](https://github.com/gtrabanco/.Sloth/blob/main/.github/code-of-conduct.md) are very welcoming.

# Roadmap

Expand Down
58 changes: 31 additions & 27 deletions dotly-migrator
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash

export DOTLY_DEFAULT_GIT_BRANCH="${DOTLY_DEFAULT_GIT_BRANCH:-main}"
export DOTLY_LOG_FILE=${DOTLY_LOG_FILE:-$HOME/dotly.log}
export DOTLY_ENV=${DOTLY_ENV:-PROD}
export DOTLY_INSTALLER=true
export DOTLY_MIGRATION=true
export SLOTH_REPOSITORY="${SLOTH_REPOSITORY:-https://github.com/gtrabanco/sloth}"
export SLOTH_REPOSITORY="${SLOTH_REPOSITORY:-https://github.com/gtrabanco/dotSloth}"
export SLOTH_INSTALLER_URL="${SLOTH_INSTALLER_URL:-https://raw.githubusercontent.com/gtrabanco/sloth/HEAD/installer}"

red='\033[0;31m'
Expand All @@ -20,7 +21,10 @@ _w() {
_a() { _w " > $1"; }
_e() { _a "${red}$1${normal}"; }
_s() { _a "${green}$1${normal}"; }
_q() { read -rp "🤔 $* : " "REPLY"; echo "${REPLY:-}"; }
_q() {
read -rp "🤔 $* : " "REPLY"
echo "${REPLY:-}"
}
_pk() { read -rp "Press a key to ${1}... 👇" "REPLY"; }

_log() {
Expand Down Expand Up @@ -70,29 +74,29 @@ if [[ -z "${DOTLY_PATH:-}" || -z "$DOTFILES_PATH" ]]; then
fi

if $DOTLY_MIGRATION; then
cp -R "$DOTFILES_PATH" "$HOME/.dotfiles.back-$(date +%s)"
cd "$DOTFILES_PATH"
# Move dotly to sloth
git mv "modules/dotly" "modules/sloth"
# Replace values in .gitmodules: path of module, branch and url
call_sed -i 's|modules/dotly|modules/sloth|g' .gitmodules
git config -f .gitmodules submodule."modules/sloth".branch "master"
git config -f .gitmodules submodule."modules/sloth".url "https://github.com/gtrabanco/sloth"
# Select master branch
cd modules/sloth || exit 4
git checkout --force master
cd ../..
# Sync submodule
git submodule sync --recursive | _log "Sync sloth module"
# Define new variables
export DOTLY_PATH="$DOTFILES_PATH/modules/sloth"
export SLOTH_PATH="$DOTFILES_PATH/modules/sloth"
export ZIM_HOME="${DOTFILES_PATH:-}/shell/zsh/.zimfw"
# Reinstall zim
zsh "$ZIM_HOME/zimfw.zsh" install
"${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" shell zsh reload_completions
#shellcheck disable=SC1091
. "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh"
"${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" migration v2.0.0
_w "🎉 Restart your terminal"
cp -R "$DOTFILES_PATH" "$HOME/.dotfiles.back-$(date +%s)"
cd "$DOTFILES_PATH"
# Move dotly to sloth
git mv "modules/dotly" "modules/sloth"
# Replace values in .gitmodules: path of module, branch and url
call_sed -i 's|modules/dotly|modules/sloth|g' .gitmodules
git config -f .gitmodules submodule."modules/sloth".branch "${DOTLY_DEFAULT_GIT_BRANCH}"
git config -f .gitmodules submodule."modules/sloth".url "${SLOTH_REPOSITORY}"
# Select master branch
cd modules/sloth || exit 4
git checkout --force "${DOTLY_DEFAULT_GIT_BRANCH}"
cd ../..
# Sync submodule
git submodule sync --recursive | _log "Sync sloth module"
# Define new variables
export DOTLY_PATH="$DOTFILES_PATH/modules/sloth"
export SLOTH_PATH="$DOTFILES_PATH/modules/sloth"
export ZIM_HOME="${DOTFILES_PATH:-}/shell/zsh/.zimfw"
# Reinstall zim
zsh "$ZIM_HOME/zimfw.zsh" install
"${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" shell zsh reload_completions
#shellcheck disable=SC1091
. "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh"
"${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" migration v2.0.0
_w "🎉 Restart your terminal"
fi
4 changes: 2 additions & 2 deletions installer
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ICLOUD_PATH="$HOME/Library/Mobile\ Documents/com~apple~CloudDocs/"
IS_ICLOUD_DOTFILES=false

DOTLY_REPOSITORY=${DOTLY_REPOSITORY:-gtrabanco/sloth}
DOTLY_BRANCH=${DOTLY_BRANCH:-master}
DOTLY_BRANCH=${DOTLY_BRANCH:-main}
DOTLY_LOG_FILE=${DOTLY_LOG_FILE:-$HOME/dotly.log}
export DOTLY_ENV=${DOTLY_ENV:-PROD}
export DOTLY_INSTALLER=true
Expand Down Expand Up @@ -400,4 +400,4 @@ _a "Installing .Sloth"
"${PWD}/bin/dot" core install 2>&1 | _log "Installing .Sloth"

_a "🎉 .Sloth was sucessfully installed! 🎉"
_a "Please, restart your terminal to see the changes"
_a "Please, restart your terminal to see the changes"
100 changes: 50 additions & 50 deletions scripts/core/install
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ start_sudo() {
}

stop_sudo() {
builtin kill "$SUDO_PID" >/dev/null 2>&1
builtin kill "$SUDO_PID" > /dev/null 2>&1
builtin trap - SIGINT SIGTERM
command -p sudo -k
}

has_sudo() {
[[ "${DOTLY_ENV:-PROD}" == "CI" ]] && return
command -p sudo -n -v >/dev/null 2>&1
command -p sudo -n -v > /dev/null 2>&1
}

initilize_sloth_if_necessary() {
if ! git::is_in_repo -C "${SLOTH_PATH:-${DOTLY_PATH:-}}" >/dev/null 2>&1; then
if ! git::is_in_repo -C "${SLOTH_PATH:-${DOTLY_PATH:-}}" > /dev/null 2>&1; then
output::answer "Initilizing .Sloth as repository"
sloth_update::sloth_repository_set_ready 2>&1 | log::file "Initilizing .Sloth as repository" || true
output::empty_line
Expand Down Expand Up @@ -97,54 +97,54 @@ else
link_prefix=/usr/local
while [[ $# -gt 0 ]]; do
case "${1:-}" in
--backup)
{ $interactive_backup || $ignore_backup; } && output::error "Error you can not use \`--backup\` with \`--interactive-backup\` or \`--ignore-backup\`" && exit 4
backup=true
;;
--interactive-backup)
{ $backup || $ignore_backup; } && output::error "Error you can not use \`--interactive-backup\` with \`--backup\` or \`--ignore-backup\`" && exit 4
interactive_backup=true
shift
;;
--ignore-backup)
{ $backup || $interactive_backup; } && output::error "Error you can not use \`--ignore-backup\` with \`--backup\` or \`--interactive-backup\`" && exit 4
ignore_backup=true
shift
;;
--ignore-symlinks)
ignore_symlinks=true
shift
;;
--ignore-loader)
ignore_loader=true
shift
;;
--ignore-restoration)
ignore_restoration=true
shift
;;
--only-git-init-sloth)
only_git_init_sloth=true
shift
;;
--ignore-link)
ignore_link=true
shift
;;
--link-prefix)
[[ -z "${2:-}" ]] && output::error "Wrong usage of \`--link-prefix\` option, it should include a second param with the prefix where to link \`dot\` command." && exit 4
link_prefix="${2:-}"
shift 2
;;
*)
break 2
;;
--backup)
{ $interactive_backup || $ignore_backup; } && output::error "Error you can not use \`--backup\` with \`--interactive-backup\` or \`--ignore-backup\`" && exit 4
backup=true
;;
--interactive-backup)
{ $backup || $ignore_backup; } && output::error "Error you can not use \`--interactive-backup\` with \`--backup\` or \`--ignore-backup\`" && exit 4
interactive_backup=true
shift
;;
--ignore-backup)
{ $backup || $interactive_backup; } && output::error "Error you can not use \`--ignore-backup\` with \`--backup\` or \`--interactive-backup\`" && exit 4
ignore_backup=true
shift
;;
--ignore-symlinks)
ignore_symlinks=true
shift
;;
--ignore-loader)
ignore_loader=true
shift
;;
--ignore-restoration)
ignore_restoration=true
shift
;;
--only-git-init-sloth)
only_git_init_sloth=true
shift
;;
--ignore-link)
ignore_link=true
shift
;;
--link-prefix)
[[ -z "${2:-}" ]] && output::error "Wrong usage of \`--link-prefix\` option, it should include a second param with the prefix where to link \`dot\` command." && exit 4
link_prefix="${2:-}"
shift 2
;;
*)
break 2
;;
esac
done
fi

if ${only_git_init_sloth:-false}; then
if platform::command_exists brew && ! brew list gtrabanco/tools/dot >/dev/null 2>&1; then
if platform::command_exists brew && ! brew list gtrabanco/tools/dot > /dev/null 2>&1; then
initilize_sloth_if_necessary
else
output::answer "Skiping init .Sloth installation as repository because you have used a package manager to install it"
Expand Down Expand Up @@ -256,7 +256,7 @@ export SETUP_ZSH_AS_DEFAULT_SHELL
export ZIM_HOME="${DOTFILES_PATH:-}/shell/zsh/.zimfw"
export PATH="$HOME/.cargo/bin:$PATH"

if platform::command_exists brew && ! brew list gtrabanco/tools/dot >/dev/null 2>&1; then
if platform::command_exists brew && ! brew list gtrabanco/tools/dot > /dev/null 2>&1; then
# Initilize .Sloth only if necessary
initilize_sloth_if_necessary
fi
Expand Down Expand Up @@ -346,7 +346,7 @@ fi
zsh_shell_path="$(command -v zsh || true)"
output::answer "Trying to setup zsh as the default shell"
if $SETUP_ZSH_AS_DEFAULT_SHELL && has_sudo; then
sudo bash -c "echo '$zsh_shell_path' | tee -a /etc/shells" >/dev/null 2>&1
sudo bash -c "echo '$zsh_shell_path' | tee -a /etc/shells" > /dev/null 2>&1

{
sudo chsh -s "$(command -v zsh)" 2>&1 || output::write "Shell could not be changed to zsh"
Expand Down Expand Up @@ -376,15 +376,15 @@ if [[ "${DOTLY_ENV:-PROD}" != "CI" ]] && platform::command_exists zsh; then
output::answer "Installing completions"

{
zsh "${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" shell zsh reload_completions >/dev/null 2>&1 &&
zsh "${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" shell zsh reload_completions > /dev/null 2>&1 &&
output::solution '✅ ZSH Completions realoaded'
} || output::error '❌ Error reloading completions. Execute later \`dot shell zsh reload_completions\`'

output::empty_line
fi

if
platform::command_exists brew && ! brew list gtrabanco/tools/dot >/dev/null 2>&1 ||
platform::command_exists brew && ! brew list gtrabanco/tools/dot > /dev/null 2>&1 ||
! ${ignore_link:-false}
then
output::answer "Linking dot command for all users in \`${link_prefix}/bin\`"
Expand Down
Loading

0 comments on commit f03d70a

Please sign in to comment.