Commenting cloudup
This commit is contained in:
parent
62004abe3e
commit
e952b32fdc
|
@ -56,6 +56,7 @@ You can use ```ytview -s [videoToSearch]``` or just ```ytview [videoToSearch]```
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Written by: <a href="http://github.com/linyostorovovoltos">Linyos Torovoltos</a>
|
||||||
|
|
||||||
## Stocks
|
## Stocks
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ Provides information about a certain stock symbol
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Written by: <a href="https://github.com/jakewmeyer">Jake Meyer
|
Written by: <a href="https://github.com/jakewmeyer">Jake Meyer</a>
|
||||||
|
|
||||||
## Currency
|
## Currency
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ A tool that facilitates backing up github repositories to bitbucket
|
||||||
|
|
||||||
If you have ever felt the fear of the github unicorn this could be your savior
|
If you have ever felt the fear of the github unicorn this could be your savior
|
||||||
|
|
||||||
Furthermore you can backup the repositories of any github user to your bitbucket.
|
Furthermore you can backup the repositories of any github user to your bitbucket.
|
||||||
|
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
@ -177,6 +178,7 @@ Valid items are: shows, books, music, artists, movies, authors, games
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
### Needs an API Key (don't worry it's free)
|
### Needs an API Key (don't worry it's free)
|
||||||
|
* Get the API key here: <a href="https://tastedive.com/account/api_access">taste dive</a>
|
||||||
* After getting the API key add the following line to your ~/.bash_profile: ```export TASTE_API_KEY="yourAPIKeyGoesHere"```
|
* After getting the API key add the following line to your ~/.bash_profile: ```export TASTE_API_KEY="yourAPIKeyGoesHere"```
|
||||||
|
|
||||||
## Qrify
|
## Qrify
|
||||||
|
@ -192,6 +194,7 @@ This is useful for sending links or saving a string of commands to your phone
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Written by: <a href="http://github.com/linyostorovovoltos">Linyos Torovoltos</a>
|
||||||
|
|
||||||
## Short
|
## Short
|
||||||
|
|
||||||
|
@ -213,6 +216,7 @@ Gets the link that is being masked by a url shortner
|
||||||
* To determine masked link behind url shortner: <a href="http://x.datasig.io">x.datasig.io</a>
|
* To determine masked link behind url shortner: <a href="http://x.datasig.io">x.datasig.io</a>
|
||||||
* To grab cheatsheets for commands and languages: <a href="http://cheat.sh/">cheat.sh</a>
|
* To grab cheatsheets for commands and languages: <a href="http://cheat.sh/">cheat.sh</a>
|
||||||
* To encode text into a qr code: <a href="http://qrenco.de">qrenco.de</a>
|
* To encode text into a qr code: <a href="http://qrenco.de">qrenco.de</a>
|
||||||
|
|
||||||
#### Inspired by: <a href="https://github.com/jakewmeyer/Ruby-Scripts">Ruby-Scripts</a>
|
#### Inspired by: <a href="https://github.com/jakewmeyer/Ruby-Scripts">Ruby-Scripts</a>
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
currentVersion="1.10.1"
|
currentVersion="1.10.1"
|
||||||
configuredClient=""
|
configuredClient=""
|
||||||
private="0"
|
private="0" ## state of private flag
|
||||||
all="0"
|
all="0" ## state of all flag
|
||||||
if [ -d ~/temp ];then rm -rf ~/temp; fi
|
if [ -d ~/temp ];then rm -rf ~/temp; fi ## if the temp folder exists we want to delete it just in case it was left over from a fatal error
|
||||||
|
|
||||||
|
|
||||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||||
|
@ -87,18 +87,22 @@ update()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## This grabs the users bitbucket info could be improved by making sure username exists
|
||||||
getBitbucketInfo()
|
getBitbucketInfo()
|
||||||
{
|
{
|
||||||
echo -n 'Enter your Bitbucket username: '
|
echo -n 'Enter your Bitbucket username: '
|
||||||
read bbUsername
|
read bbUsername
|
||||||
|
if [[ $bbUsername == "1" ]];then
|
||||||
|
echo "Using github username as bitbucket username"
|
||||||
|
fi
|
||||||
echo -n 'Enter your Bitbucket password: '
|
echo -n 'Enter your Bitbucket password: '
|
||||||
read -s password # -s flag hides password text;
|
read -s password # -s flag hides password text;
|
||||||
}
|
}
|
||||||
|
|
||||||
backupRepo()
|
backupRepo()
|
||||||
{
|
{
|
||||||
timestamp=$(date | tr " " _ | tr : _ )
|
timestamp=$(date | tr " " _ | tr : _ ) ## we do this because it takes care of changes bitbucket would have made
|
||||||
cd ~/temp/github/$repoName || return 1
|
cd ~/temp/github/$repoName || { echo "Fatal error"; return 1; }
|
||||||
if [[ $private == "1" ]];then
|
if [[ $private == "1" ]];then
|
||||||
httpGet --user $bbUsername:$password https://api.bitbucket.org/1.0/repositories/ --data name=$repoName$timestamp is_private=true > /dev/null
|
httpGet --user $bbUsername:$password https://api.bitbucket.org/1.0/repositories/ --data name=$repoName$timestamp is_private=true > /dev/null
|
||||||
echo "private"
|
echo "private"
|
||||||
|
@ -108,40 +112,43 @@ backupRepo()
|
||||||
originalRepoName=$repoName
|
originalRepoName=$repoName
|
||||||
repoName=$(echo $repoName | tr '[:upper:]' '[:lower:]')
|
repoName=$(echo $repoName | tr '[:upper:]' '[:lower:]')
|
||||||
timestamp=$(echo $timestamp | tr '[:upper:]' '[:lower:]')
|
timestamp=$(echo $timestamp | tr '[:upper:]' '[:lower:]')
|
||||||
git remote set-url origin https://$bbUsername:$password@bitbucket.org/$bbUsername/$repoName$timestamp.git > /dev/null || return 1
|
git remote set-url origin https://$bbUsername:$password@bitbucket.org/$bbUsername/$repoName$timestamp.git > /dev/null || return 1 ## switch the remote over to bitbucket rather than github
|
||||||
echo "Uploading $originalRepoName to bitbucket"
|
echo "Uploading $originalRepoName to bitbucket"
|
||||||
git push -q --progress origin --all > /dev/null || return 1
|
git push -q --progress origin --all > /dev/null || return 1 ## pushes al files to github and most of the repo history
|
||||||
echo "Uploading the tags for $originalRepoName"
|
echo "Uploading the tags for $originalRepoName"
|
||||||
git push -q --progress origin --tags > /dev/null || return 1
|
git push -q --progress origin --tags > /dev/null || return 1 ## have to push tags here since --tags and --all are mutually exclusive
|
||||||
echo "Successfully backedup $originalRepoName"
|
echo "Successfully backedup $originalRepoName"
|
||||||
rm -rf ~/temp
|
rm -rf ~/temp #if we have succesfully backedup the repo we dion't need this anymore and if we do we will recreate it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
## When cloudup is called with no flags
|
||||||
getGitHubRepoInfo()
|
getGitHubRepoInfo()
|
||||||
{
|
{
|
||||||
echo -n 'Enter the name of the repostiory to backup: '
|
echo -n 'Enter the name of the repostiory to backup: '
|
||||||
read repoName # -s flag hides password text
|
read repoName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## This grabs github user info could be improved upon by checking if user exists
|
||||||
getGitHubUserInfo()
|
getGitHubUserInfo()
|
||||||
{
|
{
|
||||||
echo -n 'Enter your Github username: '
|
echo -n 'Enter your Github username: '
|
||||||
read ghUsername
|
read ghUsername
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## function that handles cloning a repository it uses $ghUsername and $repoName
|
||||||
cloneGitHubRepo()
|
cloneGitHubRepo()
|
||||||
{
|
{
|
||||||
mkdir ~/temp
|
mkdir ~/temp
|
||||||
cd
|
cd || { echo "Fatal error"; return 1; }
|
||||||
mkdir ~/temp/github
|
mkdir ~/temp/github || { echo "Fatal error"; return 1; }
|
||||||
cd ~/temp/github
|
cd ~/temp/github || { echo "Fatal error"; return 1; }
|
||||||
echo "Cloning $repoName"
|
echo "Cloning $repoName"
|
||||||
git clone -q --progress https://github.com/$ghUsername/$repoName || return 1
|
git clone -q --progress https://github.com/$ghUsername/$repoName || return 1
|
||||||
echo "Successfully cloned $repoName"
|
echo "Successfully cloned $repoName"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Grabs the last 100 updated repos and greps to grab the repository names and puts them in an array called repoNames
|
||||||
getGithubRepoNames()
|
getGithubRepoNames()
|
||||||
{
|
{
|
||||||
response=$(httpGet "https://api.github.com/users/$ghUsername/repos?sort=updated&per_page=100" | grep -Eo '"name": "[ a-Z . \/ \\ 0-9 -- _ ]*' | sed s/'"name": "'/""/g)
|
response=$(httpGet "https://api.github.com/users/$ghUsername/repos?sort=updated&per_page=100" | grep -Eo '"name": "[ a-Z . \/ \\ 0-9 -- _ ]*' | sed s/'"name": "'/""/g)
|
||||||
|
@ -213,7 +220,7 @@ elif [ $# -ge 1 ];then
|
||||||
getBitbucketInfo || exit 1
|
getBitbucketInfo || exit 1
|
||||||
echo
|
echo
|
||||||
if [[ $private != "1" ]];then
|
if [[ $private != "1" ]];then
|
||||||
for i in "$@"; do
|
for i in "$@"; do ## if private is not on as a flag start rpping through them
|
||||||
repoName=$i
|
repoName=$i
|
||||||
echo "Starting to backup $repoName"
|
echo "Starting to backup $repoName"
|
||||||
cloneGitHubRepo || exit 1
|
cloneGitHubRepo || exit 1
|
||||||
|
@ -235,13 +242,23 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if [[ $all == "0" ]];then
|
if [[ $all == "0" ]];then
|
||||||
getGitHubUserInfo || exit 1
|
if [[ $1 == "" ]];then
|
||||||
getGitHubRepoInfo || exit 1
|
getGitHubUserInfo || exit 1
|
||||||
getBitbucketInfo || exit 1
|
getGitHubRepoInfo || exit 1
|
||||||
echo
|
getBitbucketInfo || exit 1
|
||||||
cloneGitHubRepo || exit 1
|
echo
|
||||||
backupRepo || { echo "Error: couldnt backup $originalRepoName to bitbucket"; exit 1; }
|
cloneGitHubRepo || exit 1
|
||||||
exit 0
|
backupRepo || { echo "Error: couldnt backup $originalRepoName to bitbucket"; exit 1; }
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
getGitHubUserInfo || exit 1
|
||||||
|
repoName=$1 || exit 1
|
||||||
|
getBitbucketInfo || exit 1
|
||||||
|
echo
|
||||||
|
cloneGitHubRepo || exit 1
|
||||||
|
backupRepo || { echo "Error: couldnt backup $originalRepoName to bitbucket"; exit 1; }
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
getGitHubUserInfo || exit 1
|
getGitHubUserInfo || exit 1
|
||||||
getGithubRepoNames || exit 1
|
getGithubRepoNames || exit 1
|
||||||
|
|
Loading…
Reference in New Issue