Skip to content

Commit

Permalink
Migrate master to main
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrabanco committed Jun 28, 2024
1 parent 1e6e52d commit df93397
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 220 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
24 changes: 12 additions & 12 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 @@ -54,13 +54,13 @@ _log() {
current_date=$(date "+%Y-%m-%d %H:%M:%S")

touch "$DOTLY_LOG_FILE"
echo "----- $current_date - $log_name -----" >> "$DOTLY_LOG_FILE"
echo "----- $current_date - $log_name -----" >>"$DOTLY_LOG_FILE"

while IFS= read -r log_message; do
echo "$log_message" >> "$DOTLY_LOG_FILE"
echo "$log_message" >>"$DOTLY_LOG_FILE"
done

echo "" >> "$DOTLY_LOG_FILE"
echo "" >>"$DOTLY_LOG_FILE"
}

current_timestamp() { date +%s; }
Expand All @@ -81,15 +81,15 @@ create_dotfiles_dir() {
}

command_exists() {
type "$1" > /dev/null 2>&1
type "$1" >/dev/null 2>&1
}

is_macos() {
[[ "$(uname -s)" == Darwin ]]
}

is_clt_installed() {
command -vp xcode-select > /dev/null 2>&1 && xpath=$(command -p xcode-select --print-path) && test -d "${xpath}" && test -x "${xpath}"
command -vp xcode-select >/dev/null 2>&1 && xpath=$(command -p xcode-select --print-path) && test -d "${xpath}" && test -x "${xpath}"
}

install_clt() {
Expand All @@ -116,7 +116,7 @@ install_clt() {
if ! is_clt_installed && command -p sudo -v -B; then
command -p xcode-select --install
if [[ "${DOTLY_ENV:-PROD}" != "CI" ]]; then
until command -p xcode-select --print-path > /dev/null 2>&1; do
until command -p xcode-select --print-path >/dev/null 2>&1; do
_a "Waiting for Command Line tools to be installed... Check again in 10 secs"
sleep 10
done
Expand Down Expand Up @@ -150,17 +150,17 @@ 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
}

if command -v brew > /dev/null 2>&1; then
if command -v brew >/dev/null 2>&1; then
eval "$(command brew shellenv)"
else
PATH="/usr/local/bin:/opt/homebrew/bin:/home/.linuxbrew/bin:${HOME}/.homebrew/bin:${HOME}/.brew/bin:${HOME}/.linuxbrew/bin${PATH:+:$PATH}"
Expand Down Expand Up @@ -338,7 +338,7 @@ if ! command_exists git; then
if is_macos; then
_a "Checking if Command Line Tools are installed 🕵️‍♂️"

xcode-select --install 2>&1 | grep installed > /dev/null
xcode-select --install 2>&1 | grep installed >/dev/null
if [[ $? ]]; then
_a "Installing Command Line Tools 📺"
xcode-select --install
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"
Loading

0 comments on commit df93397

Please sign in to comment.