-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from justcoded/develop
First release
- Loading branch information
Showing
15 changed files
with
511 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
# tabs 4 spaces for makefiles | ||
[Makefile] | ||
indent_size = 4 | ||
indent_style = tab | ||
[*.mk] | ||
indent_size = 4 | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# phpstorm/netbeans/eclipse project files | ||
.idea | ||
.vscode | ||
nbproject | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# windows/Mac thumbnail cache | ||
Thumbs.db | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!--- BEGIN HEADER --> | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
--- | ||
<!--- END HEADER --> | ||
|
||
## [1.0.0]() (2022-05-09) | ||
### Features | ||
|
||
* `browse` command | ||
* `jc-config` command | ||
* `jc-feature` command | ||
* `jc-hotfix` command | ||
* `lk-feature` command | ||
* `lk-epic` command | ||
* `lk-hotfix` command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.PHONY: default install | ||
|
||
default: | ||
@echo 'Git extras installation helper from JustCoded' | ||
|
||
install: | ||
sudo cp -f ./bin/* /usr/local/bin/ | ||
sudo chmod +x /usr/local/bin/git-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
# git-extras | ||
# Custom git commands | ||
|
||
## Requirements | ||
|
||
* make utility | ||
* sudo access to be able to complete the installation | ||
|
||
## Installation | ||
|
||
* Clone the repository to some folder | ||
* To install/update git extra commands just run | ||
|
||
```bash | ||
make install | ||
``` | ||
|
||
## Commands reference | ||
|
||
| Command | Description | | ||
|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------| | ||
| `git browse` | Opens remote repository URL in browser. Taken from [git-extras](https://github.com/tj/git-extras). | | ||
| `git jc-config` | Configures repository with default global filemode (or 'false' by default) and push strategy. | | ||
| `git jc-gitflow` | Creates if not exists `develop`/`release` branches or sync them. | | ||
| `git jc-feature <shortDescription>` | Defines git branching flow ("gitflow" or "feature branch") and creates Feature branch from the right branch (develop or main/master) | | ||
| `git jc-hotfix <shortDescription>` | Creates Hotfix branch from `main`/`master` branch. | | ||
| `git lk-feature <shortDescription>` | Creates Feature branch from `release`. | | ||
| `git lk-epic <shortDescription>` | Creates Epic branch from `release`. | | ||
| `git lk-hotfix <shortDescription>` | Creates Hotfix branch from `main`/`master` branch. | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ $1 == "" ]] | ||
then | ||
branch=$(git rev-parse --abbrev-ref HEAD 2&> /dev/null) | ||
remote=$(git config branch."${branch}".remote || echo "origin") | ||
else | ||
remote=$1 | ||
fi | ||
|
||
if [[ $remote == "" ]] | ||
then | ||
echo "Remote not found" | ||
exit 1 | ||
fi | ||
|
||
remote_url=$(git remote get-url $remote) | ||
|
||
if [[ $? -ne 0 ]] | ||
then | ||
exit $? | ||
fi | ||
|
||
if [[ $remote_url = git@* ]] | ||
then | ||
url=$(echo $remote_url | sed -E -e 's/:/\//' -e 's/\.git$//' -e 's/.*@(.*)/http:\/\/\1/') | ||
elif [[ $remote_url = http* ]] | ||
then | ||
url=${remote_url%.git} | ||
fi | ||
|
||
case "$OSTYPE" in | ||
darwin*) | ||
# MacOS | ||
open $url | ||
;; | ||
msys) | ||
# Git-Bash on Windows | ||
start $url | ||
;; | ||
linux*) | ||
# Handle WSL on Windows | ||
if uname -a | grep -i -q Microsoft && command -v powershell.exe | ||
then | ||
powershell.exe -NoProfile start $url | ||
else | ||
xdg-open $url | ||
fi | ||
;; | ||
*) | ||
# fall back to xdg-open for BSDs, etc. | ||
xdg-open $url | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#!/usr/bin/env bash | ||
|
||
function safeExit() { | ||
exit 0 | ||
} | ||
|
||
function error() { | ||
exit 1; | ||
} | ||
|
||
############## Default values ################### | ||
scriptName="git jc-branch" | ||
scriptArgs="<shortDescription>" | ||
namePrefix=feature/ | ||
parentBranch=develop | ||
args=() | ||
|
||
|
||
############## Main Script Here ################### | ||
|
||
function handle() { | ||
|
||
if [ -z "${args[0]}" ] | ||
then | ||
echo -e 'ERROR! Issue short description is missing.\n'; | ||
usage; | ||
error; | ||
fi; | ||
|
||
echo 'Fetching remote changes...'; | ||
git fetch; | ||
|
||
branchName="${namePrefix}${args[0]}"; | ||
|
||
echo '---------------------------------------'; | ||
echo "Creating [${branchName}] branch of [origin/${parentBranch}]..."; | ||
git switch -c ${branchName} origin/${parentBranch}; | ||
|
||
echo '---------------------------------------'; | ||
echo 'Push and set it upstream...'; | ||
git push --set-upstream origin ${branchName}; | ||
|
||
} | ||
|
||
############## Begin Options and Usage ################### | ||
|
||
# Print usage | ||
usage() { | ||
echo -n "${scriptName} [OPTIONS] ${scriptArgs} | ||
Creates feature branch off of origin/develop. | ||
Options: | ||
-h, --help Display this help and exit | ||
-p, --prefix Branch name prefix, default 'feature/' | ||
-s, --src Parent branch | ||
" | ||
} | ||
|
||
# Iterate over options breaking -ab into -a -b when needed and --foo=bar into | ||
# --foo bar | ||
optstring=h | ||
unset options | ||
while (($#)); do | ||
case $1 in | ||
# If option is of type -ab | ||
-[!-]?*) | ||
# Loop over each character starting with the second | ||
for ((i=1; i < ${#1}; i++)); do | ||
c=${1:i:1} | ||
|
||
# Add current char to options | ||
options+=("-$c") | ||
|
||
# If option takes a required argument, and it's not the last char make | ||
# the rest of the string its argument | ||
if [[ $optstring = *"$c:"* && ${1:i+1} ]]; then | ||
options+=("${1:i+1}") | ||
break | ||
fi | ||
done | ||
;; | ||
|
||
# If option is of type --foo=bar | ||
--?*=*) options+=("${1%%=*}" "${1#*=}") ;; | ||
# add --endopts for -- | ||
--) options+=(--endopts) ;; | ||
# Otherwise, nothing special | ||
*) options+=("$1") ;; | ||
esac | ||
shift | ||
done | ||
set -- "${options[@]}" | ||
unset options | ||
|
||
# Print help if no arguments were passed. | ||
# Uncomment to force arguments when invoking the script | ||
# [[ $# -eq 0 ]] && set -- "--help" | ||
|
||
# Read the options and set stuff | ||
while [[ $1 = -?* ]]; do | ||
case $1 in | ||
-h|--help) usage >&2; safeExit ;; | ||
-p|--prefix) shift; namePrefix=${1} ;; | ||
-s|--src) shift; parentBranch=${1} ;; | ||
--endopts) shift; break ;; | ||
*) die "invalid option: '$1'." ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Store the remaining part as arguments. | ||
args+=("$@") | ||
|
||
############## End Options and Usage ################### | ||
|
||
|
||
############## Script Run Code ################### | ||
|
||
# Set IFS to preferred implementation | ||
IFS=$'\n\t' | ||
|
||
# Exit on error. Append '||true' when you run the script if you expect an error. | ||
set -o errexit | ||
|
||
# Bash will remember & return the highest exitcode in a chain of pipes. | ||
# This way you can catch the error in case mysqldump fails in `mysqldump |gzip`, for example. | ||
set -o pipefail | ||
|
||
# Run your script | ||
handle | ||
|
||
# Exit cleanly | ||
safeExit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo 'Updating git configurations...'; | ||
|
||
# get global defined config | ||
filemode=$(git config --global core.filemode) | ||
# set default as 'false' if not defined. | ||
if [ -z "${filemode}" ] | ||
then | ||
filemode='false' | ||
fi; | ||
git config core.filemode ${filemode}; | ||
echo " set tracking filemode changes to [${filemode}]"; | ||
|
||
git config push.default simple; | ||
echo " set simple push strategy"; | ||
|
||
echo "Done."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
devBranchSearch=$(git branch -r | grep origin/develop) | ||
if [ -n "${devBranchSearch}" ] | ||
then | ||
echo 'Found [origin/develop] branch, using "Gitflow" workflow!'; | ||
echo '---------------------------------------'; | ||
git jc-branch -p feature/ -s develop "$@"; | ||
exit 0; | ||
fi; | ||
|
||
echo 'NOT FOUND [origin/develop] branch, using "Feature branch" workflow!'; | ||
echo '---------------------------------------'; | ||
|
||
# define main branch name: main|master | ||
mainBranch=master | ||
mainBranchSearch=$(cat .git/config | grep "branch\s\"${mainBranch}\"") | ||
|
||
if [ -z "${mainBranchSearch}" ] | ||
then | ||
mainBranch=main; | ||
fi; | ||
|
||
echo "Found maturity branch [${mainBranch}]"; | ||
echo '---------------------------------------'; | ||
|
||
git jc-branch -p feature/ -s ${mainBranch} "$@"; | ||
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
git fetch; | ||
|
||
echo 'Initializing gitflow long-live branches...'; | ||
|
||
# define main branch name: main|master | ||
mainBranch=master | ||
mainBranchSearch=$(cat .git/config | grep "branch\s\"${mainBranch}\"") | ||
|
||
if [ -z "${mainBranchSearch}" ] | ||
then | ||
mainBranch=main; | ||
fi; | ||
|
||
echo " find maturity branch [${mainBranch}]"; | ||
|
||
# find develop branch | ||
echo '-----------------------------------------------'; | ||
echo 'Checking develop branch...'; | ||
|
||
devBranchSearch=$(git branch -r | grep origin/develop) | ||
if [ -z "${devBranchSearch}" ] | ||
then | ||
git switch -c develop origin/${mainBranch}; | ||
git push --set-upstream origin develop | ||
echo ' created integration branch [develop]'; | ||
else | ||
echo ' found integration branch [origin/develop], syncing...'; | ||
git switch develop; | ||
git pull; | ||
fi; | ||
|
||
# find release branch | ||
echo '-----------------------------------------------'; | ||
echo 'Checking release branch...'; | ||
|
||
rcBranchSearch=$(git branch -r | grep origin/release) | ||
if [ -z "${rcBranchSearch}" ] | ||
then | ||
git switch -c release origin/develop; | ||
git push --set-upstream origin release | ||
echo ' created release candidate branch [release]'; | ||
else | ||
echo ' found release candidate branch [origin/release], syncing...'; | ||
git switch release; | ||
git pull; | ||
fi; | ||
|
||
# switch to develop | ||
echo '-----------------------------------------------'; | ||
echo 'Finalizing...'; | ||
|
||
echo ' switching to develop.'; | ||
git switch develop; | ||
|
||
echo 'Done.'; |
Oops, something went wrong.