MCPcopy
hub / github.com/gitless-vcs/gitless / _do_create

Function _do_create

gitless/cli/gl_branch.py:117–148  ·  view source on GitHub ↗
(create_b, dp, repo)

Source from the content-addressed store, hash-verified

115
116
117def _do_create(create_b, dp, repo):
118 errors_found = False
119
120 try:
121 target = repo.revparse_single(dp)
122 except KeyError:
123 raise ValueError('Invalid divergent point {0}'.format(dp))
124
125 for b_name in create_b:
126 r = repo
127 remote_str = ''
128 if '/' in b_name: # might want to create a remote branch
129 maybe_remote, maybe_remote_branch = b_name.split('/', 1)
130 if maybe_remote in repo.remotes:
131 r = repo.remotes[maybe_remote]
132 b_name = maybe_remote_branch
133 conf_msg = 'Branch {0} will be created in remote repository {1}'.format(
134 b_name, maybe_remote)
135 if not pprint.conf_dialog(conf_msg):
136 pprint.msg(
137 'Aborted: creation of branch {0} in remote repository {1}'.format(
138 b_name, maybe_remote))
139 continue
140 remote_str = ' in remote repository {0}'.format(maybe_remote)
141 try:
142 r.create_branch(b_name, target)
143 pprint.ok('Created new branch {0}{1}'.format(b_name, remote_str))
144 except ValueError as e:
145 pprint.err(e)
146 errors_found = True
147
148 return not errors_found
149
150
151def _do_delete(delete_b, repo):

Callers 1

mainFunction · 0.70

Calls 2

revparse_singleMethod · 0.80
create_branchMethod · 0.45

Tested by

no test coverage detected