diff --git a/1ano/1semestre/README.md b/1ano/1semestre/README.md index 7d82296..80331b5 100644 --- a/1ano/1semestre/README.md +++ b/1ano/1semestre/README.md @@ -1,11 +1,11 @@ # 1º Semestre ## Todo o material das cadeiras do 1º semestre do 1º ano: -- [Fundamentos de Programação](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/fp) | Ano de conclusão: 2022/2023 -- [Introdução à Engenharia Informática](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/iei) | Ano de conclusão: 2022/2023 -- [Introdução aos Sistemas Digitais](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/isd) | Ano de conclusão: 2022/2023 +- [Fundamentos de Programação](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/fp) +- [Introdução à Engenharia Informática](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/iei) +- [Introdução aos Sistemas Digitais](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/isd) - [Álgebra Linear e Geometria Analítica](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/alga) -- [Cálculo - 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/c1) | Ano de conclusão: 2022/2023 +- [Cálculo - 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/c1) --- *Pode conter erros, caso encontre algum, crie um* [*ticket*](https://github.com/TiagoRG/uaveiro-leci/issues/new) diff --git a/1ano/README.md b/1ano/README.md index 2c51d42..01c22fb 100755 --- a/1ano/README.md +++ b/1ano/README.md @@ -2,11 +2,11 @@ ## Todo o material das cadeiras do 1º ano: ### [1º Semestre](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre) -- [Fundamentos de Programação](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/fp) | Ano de conclusão: 2022/2023 -- [Introdução à Engenharia Informática](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/iei) | Ano de conclusão: 2022/2023 -- [Introdução aos Sistemas Digitais](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/isd) | Ano de conclusão: 2022/2023 -- [Álgebra Linear e Geometria Analítica](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/alga) |  -- [Cálculo - 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/c1) | Ano de conclusão: 2022/2023 +- [Fundamentos de Programação](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/fp) +- [Introdução à Engenharia Informática](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/iei) +- [Introdução aos Sistemas Digitais](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/isd) +- [Álgebra Linear e Geometria Analítica](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/alga) +- [Cálculo - 1](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/1semestre/c1) ### [2º Semestre](https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre) diff --git a/tools/git-tools/README.md b/tools/git-tools/README.md new file mode 100644 index 0000000..7a86c28 --- /dev/null +++ b/tools/git-tools/README.md @@ -0,0 +1,24 @@ +# git-safe-push + +## Description + +This script is used to push the local changes to the remote repository safely. Instead of pushing directly into the main branch, creates a temporary branch that can be safely deleted after the changes are reviewed and merged. This way you don't have to keep many branches in your remote repository which means it's easier to keep a linear commit history ([Squash and Merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits) suggested for this aswell). + +## Usage + +Download the script and then add it to bin with the following commands: + +```bash +sudo mv git-safe-push /usr/bin +sudo chmod +x /usr/bin/git-safe-push +``` + +Then you can use it like this: + +```bash +git safe-push <-n|-e> +``` +- ``: The remote repository to push to. +- ``: The branch to push to. +- `-n`: Pushes to a new branch. +- `-e`: Pushes to an existing branch. diff --git a/tools/git-tools/git-safe-push b/tools/git-tools/git-safe-push new file mode 100644 index 0000000..9c9ae68 --- /dev/null +++ b/tools/git-tools/git-safe-push @@ -0,0 +1,99 @@ +# Handles the arguments +# git-safe-push <-n|-e> +if [ $# -eq 0 ]; then + remote="origin" + branch="temp" + branch_option="-n" +elif [ $# -eq 1 ]; then + remote=$1 + branch="temp" + branch_option="-n" +elif [ $# -eq 2 ]; then + remote=$1 + branch=$2 + branch_option="-n" +elif [ $# -eq 3 ]; then + remote=$1 + branch=$2 + branch_option=$3 +else + echo "Usage: git-safe-push <-n/-e>" + exit +fi + +if git rev-parse --is-inside-work-tree > /dev/null; then + if git ls-remote --exit-code "$remote" >/dev/null 2>/dev/null; then + # Rebases the repository + git config pull.rebase true + git pull + + remote_link=$(git remote get-url "$remote") + link=${remote_link%.git} + + if [ "$branch_option" = "-n" ]; then + # Checks if branch exists in the remote + printf "\nChecking for %s...\n\n" "$branch" + exists_in_remote=$(git ls-remote --heads "$remote" "$branch") + + # If the branch does not exist + if [ -z "$exists_in_remote" ]; then + # Creates the branch, pushes it and deletes the branch locally + git branch "$branch" + git push "$remote" "$branch" + git branch -d "$branch" >/dev/null 2>/dev/null + + # Prints output message + printf "\n----------------------------------------------------------------\n\n Branch does not yet exist, pushed to %s/%s...\n\n You can now create a pull request at:\n > %s/compare/%s\n\n----------------------------------------------------------------\n\n" "$remote" "$branch" "$link" "$branch" + else + # Makes sure to get a free indexed temporary branch + for i in $(seq 1 100) ; do + # Checks if branch exists in the remote + printf "Checking for %s...\n" "$branch$i" + exists_in_remote=$(git ls-remote --heads "$remote" "$branch$i") + + # If the branch does not exist + if [ -z "$exists_in_remote" ]; then + # Creates the branch, pushes it and deletes the branch locally + git branch "$branch$i" + git push "$remote" "$branch$i" + git branch -d "$branch$i" >/dev/null 2>/dev/null + break + else + printf "Branch already exists, trying again...\n\n" + fi + done + # Prints output message + printf "\n----------------------------------------------------------------\n\n Branch does not yet exist, pushed to %s/%s...\n\n You can now create a pull request at:\n > %s/compare/%s\n\n----------------------------------------------------------------\n\n" "$remote" "$branch$i" "$link" "$branch$i" + fi + else + # Checks if branch exists in the remote + printf "\nChecking for %s...\n" "$branch" + exists_in_remote=$(git ls-remote --heads "$remote" "$branch") + + # If the branch does not exist + if [ -z "$exists_in_remote" ]; then + printf "\n----------------------------------------------------------------\n\n Branch does not exist, aborting...\n\n----------------------------------------------------------------\n\n" + exit + fi + # Creates the branch, pushes it and deletes the branch locally + git branch "$branch" + result=$(git push "$remote" "$branch") + if ! echo "$result" | grep -q "Everything up-to-date"; then + git branch -d "$branch" >/dev/null 2>/dev/null + printf "\n----------------------------------------------------------------\n\n Branch is up-to-date, aborting...\n\n----------------------------------------------------------------\n\n" + exit + elif ! echo "$result" | grep -q "To $remote.git"; then + git branch -d "$branch" >/dev/null 2>/dev/null + printf "\n----------------------------------------------------------------\n\n Pushed to %s/%s...\n\n You can now create a pull request at:\n > %s/compare/%s\n\n----------------------------------------------------------------\n\n" "$remote" "$branch" "$link" "$branch" + else + git branch -d "$branch" >/dev/null 2>/dev/null + printf "\n----------------------------------------------------------------\n\n Failed to push to %s/%s, aborting...\n\n----------------------------------------------------------------\n\n" "$remote" "$branch" + exit + fi + fi + else + printf "\nRemote %s is unreachable for this repository.\nIf you pretend to use a different remote name specify it using: git-safe-push \nIf this is the correct name, check if the current remote url is correct.\n" "$remote" + fi +else + printf "You are currently not in a git repository." +fi diff --git a/tools/truthtable/README.md b/tools/truthtable/README.md index 07c453d..4c20f27 100644 --- a/tools/truthtable/README.md +++ b/tools/truthtable/README.md @@ -6,7 +6,7 @@ #### 1. Head over to [Release](https://github.com/TiagoRG/uaveiro-leci/releases/tag/ttb) and download the zip folder. #### 2. Extract it into any location and then open that location. #### 3. Inside the directory, right click and choose "Open in terminal" -![- Unable to load image -](https://github.com/TiagoRG/uaveiro-leci/blob/master/tools/truthtable/openInTerminal.png) +![- Unable to load image -](https://github.com/TiagoRG/uaveiro-leci/blob/main/tools/truthtable/openInTerminal.png) #### 4. Run the following commands: 1. Make sure the setup.sh is executable: `sudo chmod +x setup.sh`
2. Install the script: `./setup.sh install`