diff --git a/git_utils/README.md b/git_utils/README.md deleted file mode 100644 index ed3a7aa6..00000000 --- a/git_utils/README.md +++ /dev/null @@ -1,35 +0,0 @@ -## GIT Helpers for ManageIQ - -Following scripts iterate over core and plugins and performs useful mass operations. - -### Config - -[config.sh](config.sh) file contains basic settings, like your home and plugins directory of ManageIQ. -If you want to redefine some value, create `config.dev.sh` file (excluded from git) and override variable. - -### Repositories - -List of repositories are either generated automatically (`$custom_repo_list == 0`) or you can define your own array manually -(`$custom_repo_list == 1`). See config for example. - -### Scripts - -Following scripts are working on current (one) repository - -- [pull.sh](pull.sh): If no changes in repo, checkouts to master and pulls changes. Otherwise it lists changes -- [rebase.sh](rebase.sh): The same as pull.sh, then rebases your current branch -- [list-branches.sh](list-branches.sh): Prints local branches, current with `*` -- [list-changes.sh](list-changes.sh): Prints changes in repo -- [cleanup.sh](cleanup.sh): Deletes branches merged to master - - Without args: local branches only - - With `--with-remote` arg: also deletes merged remote branches - -For loop over all repositories, use: - -- [git-mass.sh ](git-mass.sh) - - git-mass.sh pull - - git-mass.sh rebase - - git-mass.sh list-branches - - git-mass.sh list-changes - - git-mass.sh cleanup [--with-remote] - \ No newline at end of file diff --git a/git_utils/cleanup.sh b/git_utils/cleanup.sh deleted file mode 100755 index 686b25db..00000000 --- a/git_utils/cleanup.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# Script for git cleanup - delete merged branches -# Switches to master branches -# -# Usage: cleanup.sh [--with-remote] - -case $1 in - -r|--with-remote) remote_cleanup=1;; -esac - -# This has to be run from master -git checkout master - -# Update our list of remotes -git fetch -git remote prune origin - -# Remove local fully merged branches -local_merged=$(git branch --merged master | grep -v 'master$') -if [[ -z ${local_merged} ]]; then - echo "No local branches to delete" -else - echo ${local_merged} | xargs git branch -d -fi - -has_upstream=`git branch -a | grep upstream | wc -l` - -if [[ ${remote_cleanup} -eq 1 && "$has_upstream" -gt "0" ]] -then - remote_merged=$(git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$') - if [[ -z ${remote_merged} ]]; then - echo "No remote branches to delete" - else - # Remove remote fully merged branches - echo ${remote_merged} | xargs -I% git push origin :% - fi -fi diff --git a/git_utils/config.sh b/git_utils/config.sh deleted file mode 100755 index b2e7d22e..00000000 --- a/git_utils/config.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -# You can override these values in file config.dev.sh -manageiq_root="${HOME}/Projects/ManageIQ/upstream" -plugins_dir="plugins" - -if [[ -f "./config.dev.sh" ]]; then - source "config.dev.sh" -fi - -# $custom_repo_list: -# - when 0, then all repos in $manageiq_root and plugins are used -# - when 1, user-defined list ${repositories} is used. -# Can be defined in config.dev.sh (see example below) -custom_repo_list=0 -#repositories=("${manageiq_root}" -# "${manageiq_root}/${plugins_dir}/manageiq-ui-classic" -# "${manageiq_root}/${plugins_dir}/manageiq-api") - -source repositories.sh diff --git a/git_utils/git-mass.sh b/git_utils/git-mass.sh deleted file mode 100755 index fa761779..00000000 --- a/git_utils/git-mass.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -source config.sh - -scripts_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -for path in ${repositories[@]} -do - repo=$(basename ${path}) - echo "${repo} -------------------------------------------------------" - cd ${path} - - ${scripts_dir}/$1.sh $2 -done diff --git a/git_utils/list-branches.sh b/git_utils/list-branches.sh deleted file mode 100755 index 15d6084a..00000000 --- a/git_utils/list-branches.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# List of current local branches, current with '*' - -current_branches=$(git branch) -echo "${current_branches}" diff --git a/git_utils/list-changes.sh b/git_utils/list-changes.sh deleted file mode 100755 index 30882758..00000000 --- a/git_utils/list-changes.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# Script for list your GIT changes - -current_branch=$(git rev-parse --abbrev-ref HEAD) - -if git diff-index --quiet HEAD --; then - echo "No Changes (${current_branch})" -else - git status -s -b -fi diff --git a/git_utils/pull.sh b/git_utils/pull.sh deleted file mode 100755 index d2cac8b7..00000000 --- a/git_utils/pull.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Script for git updating git branch master topology inventory plugins -# Switches to master branch - -current_branch=$(git rev-parse --abbrev-ref HEAD) - -if git diff-index --quiet HEAD --; then - git fetch --all --prune - git checkout master - - has_upstream=`git branch -a | grep upstream | wc -l` - - if [[ "$has_upstream" -gt "0" ]]; then - git pull upstream master - else - git pull origin master - fi -else - echo "Changes in branch ${current_branch}, cannot apply GIT PULL" - scripts_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - ${scripts_dir}/list-changes.sh -fi diff --git a/git_utils/rebase.sh b/git_utils/rebase.sh deleted file mode 100755 index 8e238177..00000000 --- a/git_utils/rebase.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# Script for git updating master git branch an rebase current working branch -current_branch=$(git rev-parse --abbrev-ref HEAD) - -if git diff-index --quiet HEAD --; then - echo "* Updating (rebase) branch ${current_branch}" - git fetch --all --prune - git checkout master - - has_upstream=`git branch -a | grep upstream | wc -l` - - if [[ "$has_upstream" -gt "0" ]]; then - git pull upstream master - else - git pull origin master - fi - - if [[ ${current_branch} -ne "master" ]]; then - git checkout ${current_branch} - git rebase master - fi -else - echo "Cannot update branch ${current_branch}: Modified files present" - scripts_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - ${scripts_dir}/list-changes.sh -fi diff --git a/git_utils/repositories.sh b/git_utils/repositories.sh deleted file mode 100755 index afc96cf1..00000000 --- a/git_utils/repositories.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -if [[ ${custom_repo_list} -eq 0 ]]; then - repositories=("${manageiq_root}") - idx=1 - for dir in ${manageiq_root}/${plugins_dir}/* - do - if [[ -d ${dir} ]]; then - repositories[${idx}]=${dir} - idx=$((idx+1)) - fi - done -fi