File tree 2 files changed +50
-2
lines changed
2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 1
1
import * as TT from 'typings/tutorial'
2
2
import { exec , exists } from '../node'
3
3
import logger from '../logger'
4
- import { stringify } from 'querystring'
5
4
6
- const gitOrigin = 'coderoad'
5
+ export const gitOrigin = 'coderoad'
7
6
8
7
const stashAllFiles = async ( ) : Promise < never | void > => {
9
8
// stash files including untracked (eg. newly created file)
Original file line number Diff line number Diff line change
1
+ import * as fs from 'fs'
2
+ import { exec , exists } from '../node'
3
+
4
+ interface Input {
5
+ hash : string
6
+ branch : string
7
+ }
8
+
9
+ // note: attempted to do this as a bash script
10
+ // but requires the bash script has git permissions
11
+ const reset = async ( { branch, hash } : Input ) : Promise < void > => {
12
+ // TODO: capture branch
13
+ const localBranch = 'master'
14
+
15
+ // switch to an empty branch
16
+ await exec ( {
17
+ command : 'git checkout --orphan reset-orphan-branch' ,
18
+ } )
19
+ // stash any current work
20
+ await exec ( {
21
+ command : 'git stash' ,
22
+ } )
23
+ // remove any other files
24
+ await exec ( {
25
+ command : 'git rm -rf .' ,
26
+ } )
27
+ // TODO: delete .gitignore
28
+
29
+ await exec ( {
30
+ command : `git branch -D ${ localBranch } ` ,
31
+ } )
32
+ await exec ( {
33
+ command : `git checkout -b ${ localBranch } ` ,
34
+ } )
35
+
36
+ // load git timeline
37
+ await exec ( {
38
+ command : `git fetch coderoad ${ branch } ` ,
39
+ } )
40
+ await exec ( {
41
+ command : `git merge coderoad/${ localBranch } ` ,
42
+ } )
43
+ // reset to target commit hash
44
+ await exec ( {
45
+ command : `git reset --hard ${ hash } ` ,
46
+ } )
47
+ }
48
+
49
+ export default reset
You can’t perform that action at this time.
0 commit comments