develop branch pro feature branch
This commit is contained in:
parent
bebd59e7f4
commit
ea7baf1f43
@ -22,7 +22,7 @@ def print_colored(message, color, bold=False):
|
|||||||
|
|
||||||
def create_new_branch(repo_path, branch_name):
|
def create_new_branch(repo_path, branch_name):
|
||||||
"""
|
"""
|
||||||
Create a new branch in the repository
|
Create a new branch from 'develop' branch in the repository
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
os.chdir(repo_path)
|
os.chdir(repo_path)
|
||||||
@ -35,14 +35,26 @@ def create_new_branch(repo_path, branch_name):
|
|||||||
current_branch = subprocess.check_output(['git', 'branch', '--show-current']).decode().strip()
|
current_branch = subprocess.check_output(['git', 'branch', '--show-current']).decode().strip()
|
||||||
print_colored(f"Current branch: {current_branch}", Colors.BLUE)
|
print_colored(f"Current branch: {current_branch}", Colors.BLUE)
|
||||||
|
|
||||||
print_colored("Pulling latest changes...", Colors.BLUE)
|
# Check if develop branch exists
|
||||||
|
branches = subprocess.check_output(['git', 'branch', '-a']).decode()
|
||||||
|
if 'develop' not in branches and 'origin/develop' not in branches:
|
||||||
|
print_colored("The 'develop' branch does not exist!", Colors.RED)
|
||||||
|
return False
|
||||||
|
|
||||||
|
# First checkout develop branch
|
||||||
|
subprocess.run(['git', 'checkout', 'develop'], check=True)
|
||||||
|
print_colored("Switched to the 'develop' branch", Colors.GREEN)
|
||||||
|
|
||||||
|
# Pull latest changes from develop
|
||||||
|
print_colored("Pulling latest changes from develop...", Colors.BLUE)
|
||||||
subprocess.run(['git', 'pull'], check=True)
|
subprocess.run(['git', 'pull'], check=True)
|
||||||
|
|
||||||
branches = subprocess.check_output(['git', 'branch', '-a']).decode()
|
# Check if the new branch already exists
|
||||||
if branch_name in branches:
|
if branch_name in branches:
|
||||||
print_colored(f"Branch '{branch_name}' already exists!", Colors.YELLOW)
|
print_colored(f"Branch '{branch_name}' already exists!", Colors.YELLOW)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Create new branch from develop
|
||||||
subprocess.run(['git', 'checkout', '-b', branch_name], check=True)
|
subprocess.run(['git', 'checkout', '-b', branch_name], check=True)
|
||||||
print_colored(f"Successfully created and switched to branch: {branch_name}", Colors.GREEN)
|
print_colored(f"Successfully created and switched to branch: {branch_name}", Colors.GREEN)
|
||||||
|
|
||||||
@ -124,7 +136,7 @@ or creating new branches across all repositories.
|
|||||||
epilog='''
|
epilog='''
|
||||||
Examples:
|
Examples:
|
||||||
python3 mob_repos.py # Switch to develop and pull in all repos
|
python3 mob_repos.py # Switch to develop and pull in all repos
|
||||||
python3 mob_repos.py -bc feature/GND1111-testing-repo # Create new branch in all repos
|
python3 mob_repos.py -bc feature/GND1111-testing-repo # Create new branch from develop in all repos
|
||||||
python3 mob_repos.py --help # Show this help message
|
python3 mob_repos.py --help # Show this help message
|
||||||
''',
|
''',
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter
|
formatter_class=argparse.RawDescriptionHelpFormatter
|
||||||
@ -132,7 +144,7 @@ Examples:
|
|||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-bc', '--branch-create',
|
'-bc', '--branch-create',
|
||||||
help='Create a new branch in all repositories (e.g., feature/GND1111-testing-repo)',
|
help='Create a new branch from develop in all repositories (e.g., feature/GND1111-testing-repo)',
|
||||||
metavar='BRANCH_NAME'
|
metavar='BRANCH_NAME'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user