|
1 | 1 | const React = require('react')
|
| 2 | +const { useState } = require("react"); |
2 | 3 | const { Box, Text, NewLine } = require('ink')
|
3 | 4 | const { execSync, exec } =require("child_process")
|
4 | 5 | const TextInput = require("ink-text-input").default;
|
5 | 6 |
|
6 | 7 | const MergeRevert = (props) => {
|
7 | 8 | const [commitId, setCommitId] = useState("");
|
8 | 9 |
|
| 10 | + let { refreshTab } = props; |
9 | 11 |
|
10 | 12 | //reverts merge based on git log merge-id
|
11 | 13 | let singleBranch = execSync(
|
| 14 | + //most recent commit id |
12 | 15 | 'git log --all --decorate --oneline --graph'
|
13 | 16 | ).toString().split('\n', 1)
|
14 |
| - // let branchRevert = execSync( |
15 |
| - // `git git revert -m 1 {}` |
16 |
| - // ) |
| 17 | + const branchRevert = () => { |
| 18 | + //reverts commit |
| 19 | + try { |
| 20 | + execSync(`git revert -m 1 ${commitId}`) |
| 21 | + } catch (error) { |
| 22 | + console.error('Oops, something went wrong.') |
| 23 | + } |
| 24 | + } |
17 | 25 | return (
|
18 | 26 | <Box flexDirection='column'>
|
19 | 27 | <Box><Text> </Text></Box>
|
20 |
| - <Box><Text> Please be on master branch. </Text></Box> |
| 28 | + {/* <Box><Text> Please be on master branch. </Text></Box> */} |
| 29 | + <Box><Text color='redBright'> THIS WILL DELETE ALL FILES/CHANGES MADE IN THIS COMMIT </Text></Box> |
21 | 30 | <Box flexDirection='row'>
|
22 | 31 | <Text> Latest Commit Id: </Text>
|
23 | 32 | <Text color='#f09e8c'>{singleBranch}</Text>
|
24 | 33 | </Box>
|
25 | 34 | <Box flexDirection='row'>
|
26 |
| - <Text> Please enter your desired commit Id: </Text> |
| 35 | + <Text> Please enter your commit Id: </Text> |
27 | 36 | <TextInput
|
28 | 37 | value={commitId}
|
29 | 38 | onChange={setCommitId}
|
|
0 commit comments