Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctor --masterbranch: Use the main branch instead of the master branch #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions mdk/commands/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ class DoctorCommand(Command):
'silent': True
}
),
(
['--mainbranch'],
{
'action': 'store_true',
'help': 'Check the status of the main branch'
}
),
(
['--masterbranch'],
{
'action': 'store_true',
'help': 'Check the status of the master branch'
'help': 'With the removal of the master branch in Moodle, this is now just an alias for the `--mainbranch` argument'
}
),
(
Expand Down Expand Up @@ -153,8 +160,12 @@ def run(self, args):
if args.branch or allChecks:
self.branch(args)

# Check the master branch
if args.masterbranch or allChecks:
# Check the main branch
if args.mainbranch or args.masterbranch or allChecks:
if args.masterbranch:
print('With the removal of the master branch in the Moodle repository, the `--masterbranch` argument '
'is now an alias for the `--mainbranch` argument and may be removed soon from MDK as well. '
'In the future, please use `--mainbranch` argument instead.')
self.masterbranch(args)

# Check what you see is what you get
Expand Down Expand Up @@ -287,9 +298,9 @@ def directories(self, args):
mkdir(d, 0o777)

def masterbranch(self, args):
"""Checks the current master branch and the value set in config."""
"""Checks the current main branch and the value set in config."""

print('Checking master branch')
print('Checking the main branch')

if not self._checkWorkplace():
return
Expand All @@ -305,9 +316,9 @@ def masterbranch(self, args):
return

repo = git.Git(repoPath, self.C.get('git'))
result = repo.execute(['show', 'master:version.php'])
result = repo.execute(['show', 'main:version.php'])
if result[0] != 0:
print(' Could not read the master version.php')
print(' Could not read the main version.php')
return

reBranch = re.compile(r'^\s*\$branch\s*=\s*(?P<brackets>[\'"])?([0-9]+)(?P=brackets)\s*;')
Expand All @@ -318,7 +329,7 @@ def masterbranch(self, args):

masterBranch = int(self.C.get('masterBranch'))
if not latestBranch:
print(' Oops, could not identify the mater branch')
print(' Oops, could not identify the main branch')
elif masterBranch != latestBranch:
print(' The config masterBranch is set to %d, expecting %d' % (masterBranch, latestBranch))
if args.fix:
Expand Down