File tree 6 files changed +122
-2
lines changed
6 files changed +122
-2
lines changed Original file line number Diff line number Diff line change 9
9
<about />
10
10
<exportCommitData />
11
11
<newRemote />
12
+ <initalizeGitRepository />
12
13
<cloneRepository />
13
14
</div >
14
15
</div >
@@ -22,6 +23,7 @@ import addLocalRepository from "./components/model/addLocalRepository";
22
23
import about from " ./components/model/about" ;
23
24
import exportCommitData from " ./components/model/exportCommitData" ;
24
25
import newRemote from " ./components/model/newRemote" ;
26
+ import initalizeGitRepository from " ./components/model/initalizeGitRepository" ;
25
27
import cloneRepository from ' ./components/model/cloneRepository' ;
26
28
27
29
export default {
@@ -33,7 +35,8 @@ export default {
33
35
about,
34
36
exportCommitData,
35
37
newRemote,
36
- cloneRepository
38
+ initalizeGitRepository,
39
+ cloneRepository
37
40
},
38
41
beforeCreate () {
39
42
this .$store .commit (" repository/getRepositoryList" );
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div
3
+ v-if =" isGitRepository"
4
+ class =" model--small isgit"
5
+ >
6
+ <div class =" model__section model__header" >
7
+ <h6 class =" model__header__title" >
8
+ Git not found
9
+ </h6 >
10
+ </div >
11
+ <div class =" model__section model__body" >
12
+ By default git will be initalized at the root of the project.
13
+ </div >
14
+ <div class =" model__section model__footer" >
15
+ <outlineButton
16
+ text =" Go back"
17
+ appearance =" outline"
18
+ border-color =" 00adb5"
19
+ margin-left =" auto"
20
+ @click.native =" switchRepository"
21
+ />
22
+ <primaryButton
23
+ text =" Initalize git"
24
+ margin-left =" .5rem"
25
+ @click.native =" initalizeGit"
26
+ />
27
+ </div >
28
+ </div >
29
+ </template >
30
+
31
+ <script >
32
+ import primaryButton from " ../buttons/primaryButton" ;
33
+ import outlineButton from " ../buttons/outlineButton" ;
34
+ import gitInit from " ../../git/init" ;
35
+
36
+ export default {
37
+ name: " InitalizeGitRepository" ,
38
+ components: {
39
+ primaryButton,
40
+ outlineButton
41
+ },
42
+ computed: {
43
+ currentRepository () {
44
+ return this .$store .getters [" workspace/currentRepository" ];
45
+ },
46
+ isGitRepository () {
47
+ return (this .$router .history .current .matched [0 ].path .slice (1 ) === " repository" ) && (this .currentRepository .isGit === false );
48
+ }
49
+ },
50
+ methods: {
51
+ switchRepository () {
52
+ this .$store .commit (" model/toggleModelPlaceholder" );
53
+ this .$store .dispatch (" workspace/switchWorkspaceRepository" );
54
+ this .$router .push ({ name: " welcome" });
55
+ },
56
+ initalizeGit () {
57
+ gitInit (this .currentRepository .path );
58
+ this .$store .commit (" model/toggleModelPlaceholder" );
59
+ this .$store .dispatch ({
60
+ type: " repository/updateIsGit" ,
61
+ isGit: true
62
+ });
63
+ }
64
+ }
65
+ };
66
+ </script >
67
+
68
+ <style lang="sass">
69
+ .model
70
+
71
+ & __header
72
+ border-bottom : 1px solid #eee
73
+
74
+ & __body
75
+ border-bottom : 1px solid #eee
76
+ </style >
Original file line number Diff line number Diff line change
1
+ import git from "simple-git/promise" ;
2
+
3
+ const init = async ( path ) => {
4
+ let initaliseRepository = git ( path ) ;
5
+ await initaliseRepository . init ( ) ;
6
+ } ;
7
+
8
+ export default init ;
Original file line number Diff line number Diff line change @@ -5,8 +5,21 @@ export default {
5
5
getRepositoryName ( path ) {
6
6
return path . split ( "/" ) [ path . split ( "/" ) . length - 1 ] ;
7
7
} ,
8
+ async isGitRepository ( path ) {
9
+ const validateGitRepository = git ( path ) ;
10
+ const isGit = await validateGitRepository . checkIsRepo ( ) ;
11
+ try {
12
+ return isGit ;
13
+ } catch ( error ) {
14
+ console . log ( error ) ;
15
+ }
16
+ } ,
8
17
async localRepository ( path ) {
9
18
let listRemote ;
19
+ let isGitRepo ;
20
+ this . isGitRepository ( path ) . then ( ( result ) => {
21
+ isGitRepo = result ;
22
+ } ) ;
10
23
try {
11
24
listRemote = await git ( path ) . listRemote ( [ "--get-url" ] ) ;
12
25
if ( listRemote . slice ( - 4 , - 1 ) === "git" ) {
@@ -23,6 +36,7 @@ export default {
23
36
name : this . getRepositoryName ( path ) ,
24
37
path : path ,
25
38
remote : listRemote ,
39
+ isGit : isGitRepo ,
26
40
commits : true ,
27
41
remotes : true
28
42
} ) ;
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ export default {
17
17
components: {
18
18
navbar,
19
19
sidebar
20
+ },
21
+ mounted () {
22
+ if ((this .$router .history .current .matched [0 ].path .slice (1 ) === " repository" ) && (this .$store .getters [" workspace/currentRepository" ].isGit === false )) {
23
+ this .$store .commit (" model/toggleModelPlaceholder" );
24
+ }
20
25
}
21
26
};
22
27
</script >
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const mutations = {
19
19
path : payload . path ,
20
20
name : payload . name ,
21
21
remote : payload . remote ,
22
+ isGit : payload . isGit ,
22
23
features : {
23
24
commit : payload . commits ,
24
25
remote : payload . remotes
@@ -48,10 +49,23 @@ const mutations = {
48
49
state . repositoryList [
49
50
workspace . state . workspaceRepository . index
50
51
] . features . remote = payload . remotes ;
52
+ } ,
53
+ toggleIsGit ( state , payload ) {
54
+ state . repositoryList [
55
+ workspace . state . workspaceRepository . index
56
+ ] . isGit = payload . isGit ;
51
57
}
52
58
} ;
53
59
54
- const actions = { } ;
60
+ const actions = {
61
+ updateIsGit : ( { commit } , payload ) => {
62
+ commit ( {
63
+ type : "toggleIsGit" ,
64
+ isGit : payload . isGit
65
+ } ) ;
66
+ localStorage . setItem ( "repository" , JSON . stringify ( state . repositoryList ) ) ;
67
+ }
68
+ } ;
55
69
56
70
export default {
57
71
namespaced : true ,
You can’t perform that action at this time.
0 commit comments