From b585ebcda85cfd6185b5345df50d9cbcf748d3f3 Mon Sep 17 00:00:00 2001 From: "obed.vazquez" Date: Sun, 30 Nov 2025 04:29:56 -0600 Subject: [PATCH 1/5] Fixed simple javadocs The only class should have documentation more concise in the javadocs, and it was corrected with this fix. --- README.md | 2 +- pom.xml | 2 +- .../java/org/white_sdev/utils/logging/WhiteLoggeable.java | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4ab9739..0c34c82 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A lightweight library containing shared and generic utility classes for Java-bas ## 1) What is this repository for? ### 1.1) Quick summary -Version: `1.0.8` +Version: `1.0.9` **White_Utils** is a public Java library that provides standardized and generic utility classes to simplify common operations such as logging, formatting, and general helper functions across Java and Maven projects. It is published for public consumption and is also used as a standard within White Organization. diff --git a/pom.xml b/pom.xml index c2dac60..2425a09 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ mx.whiteweb.sdev white-utils - 1.0.8 + 1.0.9 ${project.groupId}:${project.artifactId} A lightweight library containing shared and generic utility classes for Java-based projects. https://github.com/WhiteOrganization/white-utils diff --git a/src/main/java/org/white_sdev/utils/logging/WhiteLoggeable.java b/src/main/java/org/white_sdev/utils/logging/WhiteLoggeable.java index 743ff47..c9fe1b1 100644 --- a/src/main/java/org/white_sdev/utils/logging/WhiteLoggeable.java +++ b/src/main/java/org/white_sdev/utils/logging/WhiteLoggeable.java @@ -5,10 +5,7 @@ * @Slf4j * public class MyService implements WhiteLoggeable { * - * @Override - * public org.slf4j.Logger getLogger() { - * return log; - * } + * @Override public org.slf4j.Logger getLogger() { return log; } * * public void myProcess(String name, int age) { * var log = withSignature("myProcess(name, age)") From 853193ada86046f83a8703cd3f5ed7c852562f4f Mon Sep 17 00:00:00 2001 From: "obed.vazquez" Date: Sun, 30 Nov 2025 04:29:56 -0600 Subject: [PATCH 2/5] Simple hotfixes - The only class should have documentation more concise in the javadocs, and it was corrected with this fix. - Fixed badge in the README.md. - Bumped version. --- .github/workflows/build-main.yml | 24 ++++++++++++++++++++++++ README.md | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-main.yml diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml new file mode 100644 index 0000000..1d99c51 --- /dev/null +++ b/.github/workflows/build-main.yml @@ -0,0 +1,24 @@ +name: Build Main + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 8 + + - name: Build and verify + run: mvn -B -e -DskipTests=false verify diff --git a/README.md b/README.md index 0c34c82..4a2b8eb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ [![Maven Central](https://img.shields.io/maven-central/v/mx.whiteweb.sdev/white-utils.svg)](https://search.maven.org/artifact/mx.whiteweb.sdev/white-utils) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) -[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](#) +[![Build Main](https://github.com/WhiteOrganization/white-utils/actions/workflows/build-main.yml/badge.svg)](https://github.com/WhiteOrganization/white-utils/actions/workflows/build-main.yml) + + A lightweight library containing shared and generic utility classes for Java-based projects. From 9cd3b01fb610c92413744a926fe3c7d624520842 Mon Sep 17 00:00:00 2001 From: "obed.vazquez" Date: Sun, 30 Nov 2025 04:29:56 -0600 Subject: [PATCH 3/5] Simple hotfixes - The only class should have documentation more concise in the javadocs, and it was corrected with this fix. - Fixed badge in the README.md. - Bumped version. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a2b8eb..db1fbb9 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ public class MyService implements WhiteLoggeable { public void myProcess(String name, int age) { // Method chaining is supported - all logging methods return LogContext var log = withSignature("myProcess(name, age)") - .start("Processing user {} with age {}", name, age) + .start("Processing user {} with age {}", name, age); log.debug("User age is {}", age); if (age < 18) { From 6d91caf2e65e44dcdced71be59eae679e806044d Mon Sep 17 00:00:00 2001 From: "obed.vazquez" Date: Sun, 30 Nov 2025 04:29:56 -0600 Subject: [PATCH 4/5] Simple hotfixes - The only class should have documentation more concise in the javadocs, and it was corrected with this fix. - Fixed badge in the README.md. - Modified the branch-protection script and updated documentation in README.md. - Bumped version. --- README.md | 35 ++++++++++++++++++++++++++++++----- main-protection-win.bat | 10 ++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index db1fbb9..242bffd 100644 --- a/README.md +++ b/README.md @@ -73,13 +73,38 @@ This library uses: ### 3.3) Configuration Steps -#### 3.3.1) Environment Configuration -_Please execute the `main-protection-win.bat` file in the root directory of the project -to protect the main branch from being corrupted unintentionally._ +#### 3.3.1) `main` Branch Protection +In order for us to ensure that the `main` branch isn't accidentally corrupted, we're implementing a check that will prevent users from pushing directly to `main` and forces every change to be merged with a pull request. -You will require all the Development elements in your environment. +You can execute this file: [`main-protection-win.bat`](main-protection-win.bat) before editing any text, code, branches, or anything in this repository to help you with these cases. -An IDE with Maven support is suggested for you to make any modifications to the code. +#### 3.3.2) Git Alias +When executing [`main-protection-win.bat`](main-protection-win.bat), the script will open a file in notepad. + +Only if you haven't done so already, paste the following git alias script at the end of that file : + +``` +[alias] + main2branch = "!f() { \ + if [ \"$#\" -ne 1 ]; then \ + echo \"Usage: git main2branch \"; \ + exit 1; \ + fi; \ + current_branch=$(git rev-parse --abbrev-ref HEAD); \ + if [ \"$current_branch\" != \"main\" ]; then \ + echo \"Error: You must be on 'main' branch to use this alias.\"; \ + exit 1; \ + fi; \ + new_branch=$1; \ + git fetch origin main || exit 1; \ + git checkout -b \"$new_branch\" || exit 1; \ + git reset --hard origin/main || exit 1; \ + git checkout main || exit 1; \ + git reset --hard origin/main || exit 1; \ + echo \"Moved local-only commits to branch '$new_branch'.\"; \ + }; f" +``` +This script creates a new alias, `main2branch`, that takes all local commits on main, that aren't present in origin, and moves them to a new branch, with a customizable name. Usage: `git main2branch new-branch`. This is useful for situations when you accidentally commit on `main` locally, and need to move those changes to the new branch. ## 4) How to Deploy? The deployment process is automated at this point, once the new version is detected to be merge into main from a PR, a GitHub action will build the artifact and upload it to Maven Central. diff --git a/main-protection-win.bat b/main-protection-win.bat index 932b9e5..be91ad6 100644 --- a/main-protection-win.bat +++ b/main-protection-win.bat @@ -17,8 +17,10 @@ echo then >> %HOOK_FILE% echo. echo ^>^&2 "Pushing to branch $branch is not allowed. To push to this branch:" >> %HOOK_FILE% echo. echo ^>^&2 "1) Create a new branch with the commits you already have: 'git branch new-branch'" >> %HOOK_FILE% echo. echo ^>^&2 "2) Make sure you know how many commits you need to go back and the number of commits will be called 'n'" >> %HOOK_FILE% -echo. echo ^>^&2 "3) Move master back by n commits (this will delete the commits from master but not from your new branch): 'git reset --hard HEAD~n'" >> %HOOK_FILE% -echo. echo ^>^&2 "4) Checkout from the new branch and then push from there and generate a Pull Request to this branch: 'git checkout new-branch'" >> %HOOK_FILE% +echo. echo ^>^&2 "3) Move $branch back by n commits (this will delete the commits from $branch but not from your new branch): 'git reset --hard HEAD~n'" >> %HOOK_FILE% +echo. echo ^>^&2 "4) Checkout from the new branch and then push from there" >> %HOOK_FILE% +echo. echo ^>^&2 " --> You can complete points 1-4 with the `main2branch` alias. You can read more about the `main2branch` alias in the README file. If you have already configured the alias its usage is: `git main2branch `" >> %HOOK_FILE% +echo. echo ^>^&2 "5) Try to generate the Pull Request again from this branch ." >> %HOOK_FILE% echo exit 1 >> %HOOK_FILE% echo fi >> %HOOK_FILE% echo done >> %HOOK_FILE% @@ -26,6 +28,10 @@ echo done >> %HOOK_FILE% echo exit 0 >> %HOOK_FILE% echo Created pre-push hook successfully, now `push`es are blocked on the main branches. + +echo Paste the git alias script mentioned in +echo this repository's README at the end of the file that will open after you continue. pause +notepad %USERPROFILE%\.gitconfig exit REM endlocal From 25fba5cdce407a865f9a68767f0e5b7e4a5046b4 Mon Sep 17 00:00:00 2001 From: "obed.vazquez" Date: Sun, 30 Nov 2025 05:31:58 -0600 Subject: [PATCH 5/5] Fixed a problematic Alias. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 242bffd..bf4742e 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ When executing [`main-protection-win.bat`](main-protection-win.bat), the script Only if you haven't done so already, paste the following git alias script at the end of that file : ``` + [alias] main2branch = "!f() { \ if [ \"$#\" -ne 1 ]; then \ @@ -97,12 +98,12 @@ Only if you haven't done so already, paste the following git alias script at the fi; \ new_branch=$1; \ git fetch origin main || exit 1; \ - git checkout -b \"$new_branch\" || exit 1; \ - git reset --hard origin/main || exit 1; \ - git checkout main || exit 1; \ + git branch \"$new_branch\" || exit 1; \ git reset --hard origin/main || exit 1; \ echo \"Moved local-only commits to branch '$new_branch'.\"; \ + git checkout \"$new_branch\" || exit 1; \ }; f" + ``` This script creates a new alias, `main2branch`, that takes all local commits on main, that aren't present in origin, and moves them to a new branch, with a customizable name. Usage: `git main2branch new-branch`. This is useful for situations when you accidentally commit on `main` locally, and need to move those changes to the new branch.