This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bitbucket create repo Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com> * fixing pre-commit Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com> * bitbucket delete repo Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com> * removing error validation Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com> * add formula to unix folder Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com> * windows support create repo Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com> * windows support delete repo Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com> * removing csharp files Signed-off-by: JoaoDanielRufino <joaodaniel0405@gmail.com>
- Loading branch information
1 parent
64795c1
commit b869c6f
Showing
29 changed files
with
391 additions
and
0 deletions.
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,4 @@ | ||
{ | ||
"long": "Manage Bitbucket create objects", | ||
"short": "Manage Bitbucket create objects" | ||
} |
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,15 @@ | ||
FROM cimg/base:stable-20.04 | ||
|
||
USER root | ||
|
||
RUN curl -fsSL https://commons-repo.ritchiecli.io/install.sh | bash | ||
|
||
RUN mkdir /rit | ||
COPY . /rit | ||
RUN sed -i 's/\r//g' /rit/set_umask.sh | ||
RUN sed -i 's/\r//g' /rit/run.sh | ||
RUN chmod +x /rit/set_umask.sh | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["/rit/set_umask.sh"] | ||
CMD ["/rit/run.sh"] |
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,14 @@ | ||
# SH | ||
BINARY_NAME=run.sh | ||
BIN_FOLDER=bin | ||
|
||
build: bash-build docker | ||
|
||
bash-build: | ||
mkdir -p $(BIN_FOLDER) | ||
cp -r src/* $(BIN_FOLDER) | ||
mv $(BIN_FOLDER)/main.sh $(BIN_FOLDER)/$(BINARY_NAME) | ||
chmod +x $(BIN_FOLDER)/$(BINARY_NAME) | ||
|
||
docker: | ||
cp Dockerfile set_umask.sh $(BIN_FOLDER) |
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,25 @@ | ||
# Ritchie Formula | ||
|
||
## command | ||
|
||
```bash | ||
rit bitbucket create repo | ||
``` | ||
|
||
## Requirements | ||
|
||
- git installed | ||
|
||
- set bitbucket username and token credentials using | ||
|
||
```bash | ||
rit set credential | ||
``` | ||
|
||
## How to generate personal access token(app password) | ||
|
||
To generate a personal access token click [here](https://bitbucket.org/account/settings/app-passwords/) | ||
|
||
## How it works | ||
|
||
![gif](doc/bitbucket-create-repo.gif) |
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,14 @@ | ||
@echo off | ||
SETLOCAL | ||
SET BINARY_NAME=run.bat | ||
SET BIN_FOLDER=bin | ||
SET ENTRY_POINT=main.bat | ||
|
||
:build | ||
mkdir %BIN_FOLDER% | ||
xcopy src %BIN_FOLDER% /e/h/i/c | ||
cd %BIN_FOLDER% | ||
rename %ENTRY_POINT% %BINARY_NAME% | ||
exit /b 0 | ||
|
||
ENDLOCAL |
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,39 @@ | ||
{ | ||
"dockerImageBuilder": "cimg/base:stable-20.04", | ||
"inputs": [ | ||
{ | ||
"label": "Project name: ", | ||
"name": "project_name", | ||
"type": "text" | ||
}, | ||
{ | ||
"label": "Project description: ", | ||
"name": "project_description", | ||
"type": "text" | ||
}, | ||
{ | ||
"default": "false", | ||
"items": [ | ||
"false", | ||
"true" | ||
], | ||
"label": "Create a private repository?: ", | ||
"name": "private", | ||
"type": "bool" | ||
}, | ||
{ | ||
"default": " ", | ||
"label": "Workspace path (ex: /home/user/my-project)\n(Note: An empty value create a Bitbucket repo with just a README file): ", | ||
"name": "workspace_path", | ||
"type": "text" | ||
}, | ||
{ | ||
"name": "username", | ||
"type": "CREDENTIAL_BITBUCKET_USERNAME" | ||
}, | ||
{ | ||
"name": "token", | ||
"type": "CREDENTIAL_BITBUCKET_TOKEN" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
{ | ||
"long": "bitbucket command to create a repo", | ||
"short": "bitbucket command to create a repo" | ||
} |
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 @@ | ||
{ | ||
"execution": [ | ||
"local", | ||
"docker" | ||
], | ||
"os": { | ||
"deps": [], | ||
"support": [ | ||
"mac", | ||
"linux" | ||
] | ||
}, | ||
"tags": [ | ||
"bitbucket", | ||
"create", | ||
"repo" | ||
] | ||
} |
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,3 @@ | ||
#!/bin/sh | ||
umask 0011 | ||
$1 |
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,3 @@ | ||
@echo off | ||
|
||
call windows\formula\formula.bat runFormula |
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,6 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck source=/dev/null | ||
. "$(dirname "$0")"/unix/formula/formula.sh --source-only | ||
|
||
runFormula |
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,59 @@ | ||
#!/bin/bash | ||
# shellcheck disable=SC2086 | ||
|
||
checkCommand() { | ||
if ! command -v "$1" >/dev/null; then | ||
echo "Error: $1 command required" | ||
exit 1 | ||
fi | ||
} | ||
|
||
removeSpaces() { | ||
echo "${1}" | xargs | tr " " - | ||
} | ||
|
||
checkSpace() { | ||
tmp="$1" | ||
|
||
if [[ "$1" = *" "* ]]; then | ||
echo >&2 "Removing spaces from Project name..." | ||
tmp=$(removeSpaces "$1") | ||
echo >&2 "Project name without spaces: $tmp" | ||
fi | ||
|
||
echo "$tmp" | ||
} | ||
|
||
checkProjectName() { | ||
if [[ ! "$1" =~ ^[a-zA-Z0-9-]+$ ]]; then | ||
echo "Project name cannot contain special characters" | ||
exit 1 | ||
fi | ||
} | ||
|
||
runFormula() { | ||
checkCommand git | ||
|
||
PROJECT_NAME=$(checkSpace "$PROJECT_NAME") | ||
|
||
checkProjectName "$PROJECT_NAME" | ||
|
||
if [[ "$WORKSPACE_PATH" != " " ]]; then | ||
cd "$WORKSPACE_PATH" || exit 1 | ||
else | ||
mkdir "$PROJECT_NAME" | ||
cd "$PROJECT_NAME" || exit 1 | ||
echo "$PROJECT_DESCRIPTION" >> README.md | ||
fi | ||
|
||
git init | ||
|
||
git add . | ||
git commit -m "Initial Commit" | ||
curl -X POST -u "$USERNAME":"$TOKEN" -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/repositories/"$USERNAME"/"$PROJECT_NAME" -d '{"scm": "git", "is_private": '$PRIVATE'}' > /dev/null | ||
git remote add origin https://"$USERNAME":"$TOKEN"@bitbucket.org/"$USERNAME"/"$PROJECT_NAME".git | ||
|
||
git push origin master | ||
|
||
echo "✅ Repository successfully initialized with Git and added on Bitbucket!!" | ||
} |
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 @@ | ||
@echo off | ||
SETLOCAL | ||
|
||
call:%~1 | ||
goto exit | ||
|
||
:runFormula | ||
if "%WORKSPACE_PATH%" == " " ( | ||
mkdir %CURRENT_PWD%\%PROJECT_NAME% | ||
cd %CURRENT_PWD%\%PROJECT_NAME% | ||
echo %PROJECT_DESCRIPTION% >> README.md | ||
) else ( | ||
cd %WORKSPACE_PATH% | ||
) | ||
|
||
git init | ||
git add . | ||
git commit -m "Initial Commit" | ||
curl -X POST -u %USERNAME%:%TOKEN% -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/%USERNAME%/%PROJECT_NAME% -d "{\"scm\": \"git\", \"is_private\": %PRIVATE%}" > nul | ||
git remote add origin https://%USERNAME%:%TOKEN%@bitbucket.org/%USERNAME%/%PROJECT_NAME%.git | ||
git push origin master | ||
|
||
echo Repository successfully initialized with git and added on Bitbucket!! | ||
goto exit | ||
|
||
:exit | ||
ENDLOCAL | ||
exit /b |
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,4 @@ | ||
{ | ||
"long": "Manage bitbucket delete objects", | ||
"short": "Manage bitbucket delete objects" | ||
} |
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,15 @@ | ||
FROM cimg/base:stable-20.04 | ||
|
||
USER root | ||
|
||
RUN curl -fsSL https://commons-repo.ritchiecli.io/install.sh | bash | ||
|
||
RUN mkdir /rit | ||
COPY . /rit | ||
RUN sed -i 's/\r//g' /rit/set_umask.sh | ||
RUN sed -i 's/\r//g' /rit/run.sh | ||
RUN chmod +x /rit/set_umask.sh | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["/rit/set_umask.sh"] | ||
CMD ["/rit/run.sh"] |
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,14 @@ | ||
# SH | ||
BINARY_NAME=run.sh | ||
BIN_FOLDER=bin | ||
|
||
build: bash-build docker | ||
|
||
bash-build: | ||
mkdir -p $(BIN_FOLDER) | ||
cp -r src/* $(BIN_FOLDER) | ||
mv $(BIN_FOLDER)/main.sh $(BIN_FOLDER)/$(BINARY_NAME) | ||
chmod +x $(BIN_FOLDER)/$(BINARY_NAME) | ||
|
||
docker: | ||
cp Dockerfile set_umask.sh $(BIN_FOLDER) |
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,25 @@ | ||
# Ritchie Formula | ||
|
||
## command | ||
|
||
```bash | ||
rit bitbucket delete repo | ||
``` | ||
|
||
## Requirements | ||
|
||
- git installed | ||
|
||
- set bitbucket username and token credentials using | ||
|
||
```bash | ||
rit set credential | ||
``` | ||
|
||
## How to generate personal access token(app password) | ||
|
||
To generate a personal access token click [here](https://bitbucket.org/account/settings/app-passwords/) | ||
|
||
## How it works | ||
|
||
![gif](doc/bitbucket-delete-repo.gif) |
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,14 @@ | ||
@echo off | ||
SETLOCAL | ||
SET BINARY_NAME=run.bat | ||
SET BIN_FOLDER=bin | ||
SET ENTRY_POINT=main.bat | ||
|
||
:build | ||
mkdir %BIN_FOLDER% | ||
xcopy src %BIN_FOLDER% /e/h/i/c | ||
cd %BIN_FOLDER% | ||
rename %ENTRY_POINT% %BINARY_NAME% | ||
exit /b 0 | ||
|
||
ENDLOCAL |
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 @@ | ||
{ | ||
"dockerImageBuilder": "cimg/base:stable-20.04", | ||
"inputs": [ | ||
{ | ||
"label": "Bitbucket project name to delete: ", | ||
"name": "project_name", | ||
"type": "text" | ||
}, | ||
{ | ||
"name": "username", | ||
"type": "CREDENTIAL_BITBUCKET_USERNAME" | ||
}, | ||
{ | ||
"name": "token", | ||
"type": "CREDENTIAL_BITBUCKET_TOKEN" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
{ | ||
"long": "Command to delete a single bitbucket repository", | ||
"short": "Command to delete a single bitbucket repository" | ||
} |
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,17 @@ | ||
{ | ||
"execution": [ | ||
"local" | ||
], | ||
"os": { | ||
"deps": [], | ||
"support": [ | ||
"mac", | ||
"linux" | ||
] | ||
}, | ||
"tags": [ | ||
"bitbucket", | ||
"delete", | ||
"repo" | ||
] | ||
} |
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,3 @@ | ||
#!/bin/sh | ||
umask 0011 | ||
$1 |
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,3 @@ | ||
@echo off | ||
|
||
call windows\formula\formula.bat runFormula |
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,6 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck source=/dev/null | ||
. "$(dirname "$0")"/formula/formula.sh --source-only | ||
|
||
runFormula |
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,17 @@ | ||
#!/bin/bash | ||
# shellcheck disable=SC2181 | ||
|
||
checkCommand() { | ||
if ! command -v "$1" >/dev/null; then | ||
echo "Error: $1 command required" | ||
exit 1 | ||
fi | ||
} | ||
|
||
runFormula() { | ||
checkCommand git | ||
|
||
curl -X DELETE -u "$USERNAME":"$TOKEN" https://api.bitbucket.org/2.0/repositories/"$USERNAME"/"$PROJECT_NAME" | ||
|
||
echo "✅ Repository successfully deleted from Bitbucket" | ||
} |
Oops, something went wrong.