-
Notifications
You must be signed in to change notification settings - Fork 158
refactor: replace getMissingData action with checkEmptyBranch
#1134
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
654d535
refactor: replace getMissingData with checkEmptyBranch and move actio…
jescalada 05d19b0
test: add empty commitData test case for parsePush
jescalada 087fb0b
test: fix failing chain tests
jescalada 381f00f
chore: update inaccurate docstring
jescalada e7951c0
test: checkEmptyBranch cases
jescalada 3a5f600
chore: fix linter error
jescalada f851983
test: add missing user test case for checkUserPushPermission
jescalada 092aa2a
Merge branch 'main' into remove-getMissingData
jescalada f41fd50
Merge branch 'main' into remove-getMissingData
jescalada 7d67818
Update test/processors/checkCommitMessages.test.js
jescalada 028436d
Update src/proxy/processors/push-action/checkEmptyBranch.ts
jescalada ab8cf31
chore: optimize simpleGit call
jescalada 0d5b5aa
chore: fix failing test
jescalada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { Action, Step } from '../../actions'; | ||
| import simpleGit from 'simple-git'; | ||
| import { EMPTY_COMMIT_HASH } from '../constants'; | ||
|
|
||
| const isEmptyBranch = async (action: Action) => { | ||
| const git = simpleGit(`${action.proxyGitPath}/${action.repoName}`); | ||
|
|
||
| if (action.commitFrom === EMPTY_COMMIT_HASH) { | ||
|
jescalada marked this conversation as resolved.
|
||
| try { | ||
| const type = await git.raw(['cat-file', '-t', action.commitTo || '']); | ||
| const known = type.trim() === 'commit'; | ||
| if (known) { | ||
| return true; | ||
| } | ||
|
jescalada marked this conversation as resolved.
Outdated
|
||
| } catch (err) { | ||
| console.log(`Commit ${action.commitTo} not found: ${err}`); | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| }; | ||
|
|
||
| const exec = async (req: any, action: Action): Promise<Action> => { | ||
| const step = new Step('checkEmptyBranch'); | ||
|
|
||
| if (action.commitData && action.commitData.length > 0) { | ||
| return action; | ||
| } | ||
|
|
||
| if (await isEmptyBranch(action)) { | ||
| step.setError('Push blocked: Empty branch. Please make a commit before pushing a new branch.'); | ||
| action.addStep(step); | ||
| step.error = true; | ||
| return action; | ||
| } else { | ||
| step.setError('Push blocked: Commit data not found. Please contact an administrator for support.'); | ||
| action.addStep(step); | ||
| step.error = true; | ||
| return action; | ||
| } | ||
| }; | ||
|
|
||
| exec.displayName = 'checkEmptyBranch.exec'; | ||
|
|
||
| export { exec }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.