Skip to content

resources are always added by "OCW Studio Bot" in the git commit log #1753

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

Open
pdpinch opened this issue Apr 19, 2023 · 3 comments
Open

resources are always added by "OCW Studio Bot" in the git commit log #1753

pdpinch opened this issue Apr 19, 2023 · 3 comments

Comments

@pdpinch
Copy link
Member

pdpinch commented Apr 19, 2023

Steps to Reproduce

  1. Log into Studio with your user
  2. Create a site and sync some resources from gdrive, for example: https://ocw-studio-rc.odl.mit.edu/sites/peters-test-site-for-unpbulishing/type/resource/
  3. Take a look at the commit history in github, for example: https://github.mit.edu/ocw-content-rc/test101-spring-2023/commits/main

Expected Behavior

  • The commit that adds the resources should have the same user as the commit that created the course

Actual Behavior

  • All commits that a result of a gdrive sync are made by "OCW Studio Bot"

Screenshot or Screencast

image

@pt2302
Copy link
Contributor

pt2302 commented Apr 28, 2023

It looks like "OCW Studio Bot" was made the default for "anonymous commits" in this PR: mitodl/salt-ops#1523, in response to this issue: #1269.

@pdpinch
Copy link
Member Author

pdpinch commented May 2, 2023

Thanks for the context, but I don't see why these commits that add resources should be "anonymous" since there is a logged in user who clicks the "sync w/Google drive" button.

@pt2302
Copy link
Contributor

pt2302 commented May 2, 2023

That is indeed surprising. Here is the relevant code that checks whether the user is anonymous:

def git_user(self, user: User) -> InputGitAuthor:
"""
Return an InputGitAuthor object to be used as a committer.
Applies default settings for name and email if the input User is None.
"""
name = settings.GIT_DEFAULT_USER_NAME
email = settings.GIT_DEFAULT_USER_EMAIL
if user:
if features.is_enabled(features.GIT_ANONYMOUS_COMMITS):
name = f"user_{user.id}"
else:
name = user.name or user.username
email = user.email
return InputGitAuthor(name, email)

In production, features.is_enabled(features.GIT_ANONYMOUS_COMMITS) is False. However, the default user is Anonymous:

ocw-studio/main/settings.py

Lines 934 to 945 in c74cc6f

GIT_DEFAULT_USER_NAME = get_string(
name="GIT_DEFAULT_USER_NAME",
default="Anonymous",
description="The name for the default git committer",
required=False,
)
GIT_DEFAULT_USER_EMAIL = get_string(
name="GIT_DEFAULT_USER_EMAIL",
default="[email protected]",
description="The email for the default git committer",
required=False,
)
Not sure why the logged-in user information is not getting passed through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants