-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a queue system for branch-merger requests
- Loading branch information
Showing
14 changed files
with
453 additions
and
134 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
280-f9e231e | ||
281-f6e1a43 |
This file contains 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 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,22 @@ | ||
import { | ||
mergeDefaultIntoUserBranch, | ||
checkMergeDefaultIntoUserBranch, | ||
checkMergeUserIntoDefaultBranch, | ||
mergeUserIntoDefaultBranch | ||
} from "dcs-branch-merger" | ||
|
||
/** | ||
* Defines operations for syncing between default/master branch and user branch. | ||
* | ||
* Operations: | ||
* - pullFromDefault: Pull changes FROM default/master branch INTO user branch | ||
* - checkPullFromDefault: Check if user branch needs updates from default/master | ||
* - pushToDefault: Push changes FROM user branch TO default/master | ||
* - checkPushToDefault: Check if user branch can be merged into default/master | ||
*/ | ||
export const branchOperations = { | ||
pullFromDefault: mergeDefaultIntoUserBranch, | ||
checkPullFromDefault: checkMergeDefaultIntoUserBranch, | ||
pushToDefault: mergeUserIntoDefaultBranch, | ||
checkPushToDefault: checkMergeUserIntoDefaultBranch, | ||
} |
This file contains 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,14 @@ | ||
export const defaultStatus = { | ||
mergeNeeded: false, | ||
conflict: false, | ||
success: false, | ||
userBranchDeleted: false, | ||
error: false, | ||
message: "", | ||
pullRequest: "", | ||
} | ||
|
||
export const RETRY_ATTEMPTS = 3; | ||
export const RETRY_DELAY = 1000; // ms | ||
export const RATE_LIMIT_DELAY = 1000; // 1 second between API calls | ||
export const DEFAULT_AUTO_CHECK_INTERVAL = 30000; // 30 seconds |
15 changes: 15 additions & 0 deletions
15
src/components/branch-merger/context/BranchMergerContext.js
This file contains 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,15 @@ | ||
import { createContext, useContext } from 'react'; | ||
|
||
export const BranchMergerContext = createContext(null); | ||
|
||
/** | ||
* Hook to use branch merger context. | ||
* Throws if used outside of BranchMergerProvider. | ||
*/ | ||
export function useBranchMergerContext() { | ||
const context = useContext(BranchMergerContext); | ||
if (!context) { | ||
throw new Error('useBranchMergerContext must be used within a BranchMergerProvider'); | ||
} | ||
return context; | ||
} |
46 changes: 34 additions & 12 deletions
46
src/components/branch-merger/context/BranchMergerProvider.js
This file contains 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 |
---|---|---|
@@ -1,25 +1,47 @@ | ||
import React, { createContext } from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { BranchMergerContext } from './BranchMergerContext'; | ||
import useBranchMerger from '../hooks/useBranchMerger'; | ||
import { DEFAULT_AUTO_CHECK_INTERVAL } from '../constants'; | ||
|
||
export const BranchMergerContext = createContext(); | ||
/** | ||
* Provider component for branch merger functionality. | ||
* Provides branch operations and status through context. | ||
*/ | ||
export function BranchMergerProvider({ | ||
children, | ||
server, | ||
owner, | ||
repo, | ||
userBranch, | ||
tokenid, | ||
autoCheck = false, | ||
autoCheckInterval = DEFAULT_AUTO_CHECK_INTERVAL | ||
}) { | ||
const branchMerger = useBranchMerger( | ||
{ server, owner, repo, userBranch, tokenid }, | ||
{ autoCheck, autoCheckInterval } | ||
); | ||
|
||
// Memoize context value to prevent unnecessary re-renders | ||
const contextValue = useMemo(() => branchMerger, [branchMerger]); | ||
|
||
const BranchMergerProvider = ({ children, server, owner, repo, userBranch, tokenid }) => { | ||
const {state,actions} = useBranchMerger({server, owner, repo, userBranch, tokenid}) | ||
return ( | ||
<BranchMergerContext.Provider value={{state,actions}}> | ||
<BranchMergerContext.Provider value={contextValue}> | ||
{children} | ||
</BranchMergerContext.Provider> | ||
); | ||
}; | ||
} | ||
|
||
BranchMergerProvider.propTypes = { | ||
children: PropTypes.element, | ||
server: PropTypes.string, | ||
owner: PropTypes.string, | ||
repo: PropTypes.string, | ||
userBranch: PropTypes.string, | ||
tokenid: PropTypes.string, | ||
children: PropTypes.node.isRequired, | ||
server: PropTypes.string.isRequired, | ||
owner: PropTypes.string.isRequired, | ||
repo: PropTypes.string.isRequired, | ||
userBranch: PropTypes.string.isRequired, | ||
tokenid: PropTypes.string.isRequired, | ||
autoCheck: PropTypes.bool, | ||
autoCheckInterval: PropTypes.number | ||
}; | ||
|
||
export default BranchMergerProvider; |
Oops, something went wrong.