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

Commitf6c861f

Browse files
committed
add reset script
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parentcb79854 commitf6c861f

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

‎src/services/git/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import*asTTfrom'typings/tutorial'
22
import{exec,exists}from'../node'
33
importloggerfrom'../logger'
4-
import{stringify}from'querystring'
54

6-
constgitOrigin='coderoad'
5+
exportconstgitOrigin='coderoad'
76

87
conststashAllFiles=async():Promise<never|void>=>{
98
// stash files including untracked (eg. newly created file)

‎src/services/git/reset.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import*asfsfrom'fs'
2+
import{exec,exists}from'../node'
3+
4+
interfaceInput{
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+
constreset=async({ branch, hash}:Input):Promise<void>=>{
12+
// TODO: capture branch
13+
constlocalBranch='master'
14+
15+
// switch to an empty branch
16+
awaitexec({
17+
command:'git checkout --orphan reset-orphan-branch',
18+
})
19+
// stash any current work
20+
awaitexec({
21+
command:'git stash',
22+
})
23+
// remove any other files
24+
awaitexec({
25+
command:'git rm -rf .',
26+
})
27+
// TODO: delete .gitignore
28+
29+
awaitexec({
30+
command:`git branch -D${localBranch}`,
31+
})
32+
awaitexec({
33+
command:`git checkout -b${localBranch}`,
34+
})
35+
36+
// load git timeline
37+
awaitexec({
38+
command:`git fetch coderoad${branch}`,
39+
})
40+
awaitexec({
41+
command:`git merge coderoad/${localBranch}`,
42+
})
43+
// reset to target commit hash
44+
awaitexec({
45+
command:`git reset --hard${hash}`,
46+
})
47+
}
48+
49+
exportdefaultreset

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp