[FIX] script git repo: force default branch
This commit is contained in:
parent
0133ee8335
commit
b75949b11a
2 changed files with 29 additions and 11 deletions
|
|
@ -40,12 +40,22 @@ def get_config():
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Create a new manifest and clear old configuration.",
|
help="Create a new manifest and clear old configuration.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--keep_origin",
|
||||||
|
action="store_true",
|
||||||
|
help="Create origin remote. TODO.",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-m",
|
"-m",
|
||||||
"--manifest",
|
"--manifest",
|
||||||
default="manifest/default.dev.xml",
|
default="manifest/default.dev.xml",
|
||||||
help="The manifest file path to generate.",
|
help="The manifest file path to generate.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--default_branch",
|
||||||
|
default=False,
|
||||||
|
help="The manifest default branch.",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
@ -78,12 +88,16 @@ def main():
|
||||||
else:
|
else:
|
||||||
dct_remote = {}
|
dct_remote = {}
|
||||||
dct_project = {}
|
dct_project = {}
|
||||||
|
kwargs = {}
|
||||||
|
if config.default_branch:
|
||||||
|
kwargs["default_branch"] = config.default_branch
|
||||||
git_tool.generate_repo_manifest(
|
git_tool.generate_repo_manifest(
|
||||||
lst_repo_organization,
|
lst_repo_organization,
|
||||||
output=f"{config.dir}{config.manifest}",
|
output=f"{config.dir}{config.manifest}",
|
||||||
dct_remote=dct_remote,
|
dct_remote=dct_remote,
|
||||||
dct_project=dct_project,
|
dct_project=dct_project,
|
||||||
keep_original=True,
|
keep_original=config.keep_origin,
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
git_tool.generate_generate_config()
|
git_tool.generate_generate_config()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -445,6 +445,7 @@ class GitTool:
|
||||||
dct_project={},
|
dct_project={},
|
||||||
default_remote=None,
|
default_remote=None,
|
||||||
keep_original=False,
|
keep_original=False,
|
||||||
|
default_branch=DEFAULT_BRANCH,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Generate repo manifest
|
Generate repo manifest
|
||||||
|
|
@ -455,6 +456,7 @@ class GitTool:
|
||||||
:param default_remote: dict of default remote
|
:param default_remote: dict of default remote
|
||||||
:param keep_original: if True, can manage multiple organization with same name,
|
:param keep_original: if True, can manage multiple organization with same name,
|
||||||
but with different fetch url
|
but with different fetch url
|
||||||
|
:param default_branch: default branch name
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if not output:
|
if not output:
|
||||||
|
|
@ -469,15 +471,17 @@ class GitTool:
|
||||||
|
|
||||||
# Fill with configuration
|
# Fill with configuration
|
||||||
for dct_value in dct_remote.values():
|
for dct_value in dct_remote.values():
|
||||||
lst_remote.append(
|
remote_name = dct_value.get("@name")
|
||||||
OrderedDict(
|
if remote_name not in lst_remote_name:
|
||||||
[
|
lst_remote.append(
|
||||||
("@name", dct_value.get("@name")),
|
OrderedDict(
|
||||||
("@fetch", dct_value.get("@fetch")),
|
[
|
||||||
]
|
("@name", remote_name),
|
||||||
|
("@fetch", dct_value.get("@fetch")),
|
||||||
|
]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
lst_remote_name.append(remote_name)
|
||||||
lst_remote_name.append(dct_value.get("@name"))
|
|
||||||
for dct_value in dct_project.values():
|
for dct_value in dct_project.values():
|
||||||
lst_project_info = [
|
lst_project_info = [
|
||||||
("@name", dct_value.get("@name")),
|
("@name", dct_value.get("@name")),
|
||||||
|
|
@ -519,7 +523,7 @@ class GitTool:
|
||||||
OrderedDict(
|
OrderedDict(
|
||||||
[
|
[
|
||||||
("@remote", repo.original_organization),
|
("@remote", repo.original_organization),
|
||||||
("@revision", DEFAULT_BRANCH),
|
("@revision", default_branch),
|
||||||
("@sync-j", "4"),
|
("@sync-j", "4"),
|
||||||
("@sync-c", "true"),
|
("@sync-c", "true"),
|
||||||
]
|
]
|
||||||
|
|
@ -572,7 +576,7 @@ class GitTool:
|
||||||
OrderedDict(
|
OrderedDict(
|
||||||
[
|
[
|
||||||
("@remote", default_remote.get("@remote")),
|
("@remote", default_remote.get("@remote")),
|
||||||
("@revision", DEFAULT_BRANCH),
|
("@revision", default_branch),
|
||||||
("@sync-j", "4"),
|
("@sync-j", "4"),
|
||||||
("@sync-c", "true"),
|
("@sync-c", "true"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue