feat: update team naming format (#53)
This commit is contained in:
parent
4b4034c651
commit
183f4267de
|
@ -87,7 +87,7 @@ Example: `python3 -m joint_teapot create-personal-repos --suffix "-p1"` will cre
|
||||||
|
|
||||||
### `create-teams`
|
### `create-teams`
|
||||||
|
|
||||||
create teams on gitea by canvas groups
|
create teams on gitea by canvas groups. To integrate with webhooks, it's recommended to set suffix to `-gitea`.
|
||||||
|
|
||||||
### `create-webhooks-for-mm`
|
### `create-webhooks-for-mm`
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ def upload_assignment_grades(assignments_dir: Path, assignment_name: str) -> Non
|
||||||
@app.command(
|
@app.command(
|
||||||
"create-group-channels-on-mm",
|
"create-group-channels-on-mm",
|
||||||
help="create channels for student groups according to group information on"
|
help="create channels for student groups according to group information on"
|
||||||
" gitea",
|
" gitea; to integrate with webhooks, it's recommended to set suffix to '-gitea'",
|
||||||
)
|
)
|
||||||
def create_group_channels_on_mm(
|
def create_group_channels_on_mm(
|
||||||
prefix: str = Option(""),
|
prefix: str = Option(""),
|
||||||
|
@ -221,7 +221,7 @@ def create_personal_channels_on_mm(
|
||||||
"and configure them so that updates on gitea will be pushed to the mm channel",
|
"and configure them so that updates on gitea will be pushed to the mm channel",
|
||||||
)
|
)
|
||||||
def create_webhooks_for_mm(
|
def create_webhooks_for_mm(
|
||||||
regex: str = Argument(""), git_suffix: bool = Option(False)
|
regex: str = Argument(""), gitea_suffix: bool = Option(True)
|
||||||
) -> None:
|
) -> None:
|
||||||
repo_names = [
|
repo_names = [
|
||||||
group_name
|
group_name
|
||||||
|
@ -229,7 +229,9 @@ def create_webhooks_for_mm(
|
||||||
if re.match(regex, group_name)
|
if re.match(regex, group_name)
|
||||||
]
|
]
|
||||||
logger.info(f"{len(repo_names)} pair(s) of webhooks to be created: {repo_names}")
|
logger.info(f"{len(repo_names)} pair(s) of webhooks to be created: {repo_names}")
|
||||||
tea.pot.mattermost.create_webhooks_for_repos(repo_names, tea.pot.gitea, git_suffix)
|
tea.pot.mattermost.create_webhooks_for_repos(
|
||||||
|
repo_names, tea.pot.gitea, gitea_suffix
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.command(
|
@app.command(
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Teapot:
|
||||||
return None
|
return None
|
||||||
team_name, number_str = name.split(" ")
|
team_name, number_str = name.split(" ")
|
||||||
number = int(number_str)
|
number = int(number_str)
|
||||||
return f"{team_name}-{number:02}"
|
return f"{team_name}{number:02}"
|
||||||
|
|
||||||
return self.gitea.create_teams_and_repos_by_canvas_groups(
|
return self.gitea.create_teams_and_repos_by_canvas_groups(
|
||||||
self.canvas.students, self.canvas.groups, convertor, convertor
|
self.canvas.students, self.canvas.groups, convertor, convertor
|
||||||
|
|
|
@ -167,12 +167,14 @@ class Mattermost:
|
||||||
logger.info(f"Added member {member} to channel {channel_name}")
|
logger.info(f"Added member {member} to channel {channel_name}")
|
||||||
|
|
||||||
def create_webhooks_for_repos(
|
def create_webhooks_for_repos(
|
||||||
self, repos: List[str], gitea: Gitea, git_suffix: bool
|
self, repos: List[str], gitea: Gitea, gitea_suffix: bool
|
||||||
) -> None:
|
) -> None:
|
||||||
# one group corresponds to one repo so these concepts can be used interchangeably
|
# one group corresponds to one repo so these concepts can be used interchangeably
|
||||||
for repo in repos:
|
for repo in repos:
|
||||||
logger.info(f"Creating webhooks for repo {gitea.org_name}/{repo}")
|
channel_name = f"{repo}-gitea" if gitea_suffix else repo
|
||||||
channel_name = f"{repo}-git" if git_suffix else repo
|
logger.info(
|
||||||
|
f"Creating webhooks for repo {gitea.org_name}/{repo} and channel {channel_name}"
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
mm_channel = self.endpoint.channels.get_channel_by_name(
|
mm_channel = self.endpoint.channels.get_channel_by_name(
|
||||||
self.team["id"], channel_name
|
self.team["id"], channel_name
|
||||||
|
|
Loading…
Reference in New Issue
Block a user