Skip to content
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

feat(cli): deploy command should allow customizing git config user.name / user.email in deployment branch (#9101) #9102

Merged
merged 2 commits into from
Jul 3, 2023

Conversation

amdshrif
Copy link
Contributor

@amdshrif amdshrif commented Jun 25, 2023

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Fix #9101

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@facebook-github-bot
Copy link
Contributor

Hi @amdshrif!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link

netlify bot commented Jun 25, 2023

[V2]

Name Link
🔨 Latest commit 88dffb7
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/649f012dbd5883000819002e
😎 Deploy Preview https://deploy-preview-9102--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

github-actions bot commented Jun 25, 2023

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 70 🟢 97 🟢 92 🟢 100 🟠 89 Report
/docs/installation 🟠 69 🟢 100 🟢 92 🟢 100 🟠 89 Report

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 25, 2023
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this?

What prevents from replacing:

export GIT_USER_NAME="xyz"
export GIT_USER_EMAIL="my@email.com"
yarn deploy

With:

git config user.name "xyz"
git config user.email "my@email.com"
yarn deploy

Comment on lines +218 to +226
const gitUserName = process.env.GIT_USER_NAME;
if (gitUserName) {
shellExecLog(`git config user.name "${gitUserName}"`);
}

const gitUserEmail = process.env.GIT_USER_EMAIL;
if (gitUserEmail) {
shellExecLog(`git config user.email "${gitUserEmail}"`);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not super fan of having config side-effects like this, and features without documentation

@amdshrif
Copy link
Contributor Author

amdshrif commented Jun 29, 2023

Do we really need this?

What prevents from replacing:

export GIT_USER_NAME="xyz"
export GIT_USER_EMAIL="my@email.com"
yarn deploy

With:

git config user.name "xyz"
git config user.email "my@email.com"
yarn deploy

The suggested enhancement will only update the user.name and user.email locally on the repo level, while keeping the global git config as-is and I do not have to bother to keep switching between personal and work emails for every work I do on my machine.

The new enhancement works well with a local shell script that exports the other env variable settings all together.

env-setting.sh

export USE_SSH=true
export GIT_USER="amdshrif"
export CURRENT_BRANCH="deployment"
export GIT_USER_NAME="Ahmad Shrif"
export GIT_USER_EMAIL="ahmad.shrif@gmail.com"

source env-settings.sh

@slorber
Copy link
Collaborator

slorber commented Jun 30, 2023

The suggested enhancement will only update the user.name and user.email locally on the repo level, while keeping the global git config as-is and I do not have to bother to keep switching between personal and work emails for every work I do on my machine.

Sorry, but I don't understand your answer.

The suggested enhancement will only update the user.name and user.email locally on the repo level, while keeping the global git config as-is

Isn't it the intended behavior in both cases?


I'll ask again:

Does the following work to deploy with the specified username/email, yes or not?

git config user.name "Ahmad Shrif"
git config user.email "ahmad.shrif@gmail.com"
yarn deploy

Have you tested it?

If it does not work, can you tell me what's the behavior you see, and what's the behavior you want?

@slorber
Copy link
Collaborator

slorber commented Jun 30, 2023

Ok I understand the problem now, there are 2 repositories involved:

  • The current one
  • The one we clone for deployment (possibly a different one)

We need to set the config on the cloned deployment

I'm ok to merge this, but please add some documentation for these env variables

@slorber slorber changed the title feat:Enhance the deploy command to enable the setting of git user.name and user.email in deployment branch (#9101) feat(cli): deploy command should allow deployment with custom git config user.name / user.email in deployment branch (#9101) Jun 30, 2023
@slorber slorber changed the title feat(cli): deploy command should allow deployment with custom git config user.name / user.email in deployment branch (#9101) feat(cli): deploy command should allow customizing git config user.name / user.email in deployment branch (#9101) Jun 30, 2023
@slorber slorber added pr: new feature This PR adds a new API or behavior. to backport This PR is planned to be backported to a stable version of Docusaurus labels Jun 30, 2023
@amdshrif
Copy link
Contributor Author

Ok I understand the problem now, there are 2 repositories involved:

  • The current one
  • The one we clone for deployment (possibly a different one)

We need to set the config on the cloned deployment

I'm ok to merge this, but please add some documentation for these env variables

Yes, that the is correct. Actually it is one repository and two branches, when we run yarn deploy it does a clone for the repository with the selected branch in a tmp folder and pushes the changes from there.

I will update the PR to update the docs and testing.

@slorber
Copy link
Collaborator

slorber commented Jul 3, 2023

Thanks, added the docs to your pr already :)

@slorber slorber merged commit 26ae416 into facebook:main Jul 3, 2023
This was referenced Oct 19, 2023
@slorber slorber removed the to backport This PR is planned to be backported to a stable version of Docusaurus label Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance the deploy command to enable the setting of git user.name and user.email in deployment branch
3 participants