Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

validate git is configured with user.name & email#457

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 1 commit intomasterfromfix/check-git-user-configured
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletionsrc/actions/onValidateSetup.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
import * as T from 'typings'
import * as E from 'typings/error'
import { version } from '../services/dependencies'
import { checkWorkspaceEmpty } from '../services/workspace'
import { send } from '../commands'
import { validateGitConfig } from '../services/git'

const onValidateSetup = async (): Promise<void> => {
try {
Expand DownExpand Up@@ -43,6 +43,27 @@ const onValidateSetup = async (): Promise<void> => {
send({ type: 'VALIDATE_SETUP_FAILED', payload: { error } })
return
}

const isGitUserNameConfigured = await validateGitConfig('user.name')
const isGitUserEmailConfigured = await validateGitConfig('user.email')
if (!isGitUserNameConfigured || !isGitUserEmailConfigured) {
let message = ''
if (!isGitUserNameConfigured) message += 'Git user not configured.\n'
if (!isGitUserEmailConfigured) message += 'Git email not configured.'
const error: E.ErrorMessage = {
type: 'GitUserNotConfigured',
message,
actions: [
{
label: 'Check Again',
transition: 'RETRY',
},
],
}
send({ type: 'VALIDATE_SETUP_FAILED', payload: { error } })
return
}

send({ type: 'SETUP_VALIDATED' })
} catch (e) {
const error = {
Expand Down
13 changes: 13 additions & 0 deletionssrc/services/git/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -191,3 +191,16 @@ export async function commitsExistsByMessage(message: string): Promise<boolean>
return false
}
}

export async function validateGitConfig(target: string): Promise<boolean> {
try {
// returns a list of commit hashes
const { stdout, stderr } = await exec({ command: `git config ${target}` })
if (stderr) {
return false
}
return !!stdout.length
} catch (error) {
return false
}
}
1 change: 1 addition & 0 deletionstypings/error.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ export type ErrorMessageView = 'FULL_PAGE' | 'NOTIFY' | 'NONE'
export type ErrorMessageType =
| 'FailedToConnectToGitRepo'
| 'GitNotFound'
| 'GitUserNotConfigured'
| 'GitProjectAlreadyExists'
| 'GitRemoteAlreadyExists'
| 'MissingTutorialDependency'
Expand Down
1 change: 1 addition & 0 deletionsweb-app/src/services/errors/en.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
{
"FailedToConnectToGitRepo": "### Failed to Connect to Git Repo\n\nThere are several possible causes:\n\n- you may not be connected to the internet or have an unstable connection.\n- you may not have access permission to the remote tutorial repo.\n- the remote tutorial repo may not exist at the provided location",
"GitNotFound": "### Git Not Found\n\nMake sure you have Git installed.\n\nSee the [Git docs](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for help.",
"GitUserNotConfigured": "### Git User Not Configured\n\nThe first thing you should do when you install Git is to set your user name and email address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you start creating:\n```shell\ngit config --global user.name \"John Doe\"\ngit config --global user.email johndoe@example.com\n```",
"GitProjectAlreadyExists": "### Git Remote Already Exists\n\nHave you started this tutorial before in this workspace? The Git remote already exists.\n\nConsider deleting your `.git` folder and restarting.",
"GitRemoteAlreadyExists": "### Git Project Already Exists\n\nCodeRoad requires an empty Git project.\n\nOpen a new workspace to start a tutorial.",
"MissingTutorialDependency": "### Missing Tutorial Dependency\n\nThe tutorial cannot run because it a dependency is not yet installed. Install the dependency and click \"Check Again\".",
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp