Skip to content

Commit

Permalink
Remove master branch support
Browse files Browse the repository at this point in the history
The `master` branch will be removed on 12 August 2024
- Remove from version list
- No need to sync `master` with `main` during update
  • Loading branch information
junpataleta committed Aug 10, 2024
1 parent 1b72bb7 commit 26c4f14
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion mdk/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Bunch:

# Wording version
versionNice = version
if version in ['master', 'main']:
if version in ['main']:
versionNice = self.C.get('wording.master')

# Generating names
Expand Down
2 changes: 1 addition & 1 deletion mdk/commands/fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run(self, args):

stablebranch = M.get('stablebranch')
masterbranch = ''
if stablebranch in ['master', 'main']:
if stablebranch in ['main']:
# Generate a branch name for master to check later whether there's already an existing working branch.
masterbranch = M.generateBranchName(args.issue, args.suffix, 'master')

Expand Down
2 changes: 1 addition & 1 deletion mdk/commands/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def download(self, M, args):
return False

branch = M.get('branch')
if branch in ['master', 'main']:
if branch in ['main']:
branch = C.get('masterBranch')
branch = int(branch)

Expand Down
2 changes: 1 addition & 1 deletion mdk/commands/rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def run(self, args):
# Looping over each issue to rebase
for issue in issues:
branch = M.generateBranchName(issue, suffix=args.suffix)
if M.get('stablebranch') in ['master', 'main']:
if M.get('stablebranch') in ['main']:
masterbranch = M.generateBranchName(issue, args.suffix, 'master')
if M.git().hasBranch(masterbranch):
prompt = (
Expand Down
11 changes: 1 addition & 10 deletions mdk/moodle.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def _load(self):
self.version['branch'] = 'main'

# Stable branch
self.version['stablebranch'] = stableBranch(self.version['branch'], self.git())
self.version['stablebranch'] = stableBranch(self.version['branch'])

# Integration or stable?
self.version['integration'] = self.isIntegration()
Expand Down Expand Up @@ -793,15 +793,6 @@ def update(self, remote=None):
if not self.git().reset(to=upstream, hard=True):
raise Exception('Error while executing git reset.')

# Sync the master branch to the main branch.
if stablebranch == 'main' and self.git().hasBranch('master', upstreamremote):
logging.info(' Syncing the master branch to the main branch...')
# Any issues encountered here should just be logged and not break execution.
if not self.git().checkout('master'):
logging.info('Error while checking out the master branch.')
if not self.git().reset(to=upstream, hard=True):
logging.info('Error while executing git reset on the master branch.')

# Return to previous branch
self.checkout_stable(False)

Expand Down
10 changes: 3 additions & 7 deletions mdk/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,8 @@ def natural_sort_key(s, _nsre=re.compile('([0-9]+)')):
return [int(text) if text.isdigit() else text.lower() for text in _nsre.split(s)]


def stableBranch(version, git=None):
if version in ['master', 'main']:
if git is not None and not git.hasBranch('main', C.get('upstreamRemote')):
# Fall back to master if main is not yet available.
logging.info('The main branch has not been found, using master instead.')
return 'master'
def stableBranch(version):
if version in ['main']:
return 'main'
return 'MOODLE_%d_STABLE' % int(version)

Expand All @@ -244,7 +240,7 @@ def version_options():
return ([str(x) for x in range(13, 40)]
+ [str(x) for x in range(310, 312)]
+ [str(x) for x in range(400, C.get('masterBranch'))]
+ ['master', 'main'])
+ ['main'])

class ProcessInThread(threading.Thread):
"""Executes a process in a separate thread"""
Expand Down
2 changes: 1 addition & 1 deletion mdk/workplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def create(self, name=None, version='main', integration=False, useCacheAsRemote=
# Update the cached clones.
self.updateCachedClones(stable=not integration, integration=integration, verbose=False)

branch = stableBranch(version, git.Git(self.getCachedRemote(integration), C.get('git')))
branch = stableBranch(version)

useCacheAsUpstream = C.get('useCacheAsUpstreamRemote')
cloneAsShared = useCacheAsUpstream and C.get('useCacheAsSharedClone')
Expand Down

0 comments on commit 26c4f14

Please sign in to comment.