Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
55b91d94
Commit
55b91d94
authored
May 01, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed staged files not being recognised
reduced code duplication
parent
cac07a46
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
app/assets/javascripts/ide/stores/getters.js
app/assets/javascripts/ide/stores/getters.js
+7
-15
app/assets/javascripts/ide/stores/utils.js
app/assets/javascripts/ide/stores/utils.js
+6
-0
No files found.
app/assets/javascripts/ide/stores/getters.js
View file @
55b91d94
import
{
__
}
from
'
~/locale
'
;
import
{
getChangesCountForState
,
filePathMatches
}
from
'
./utils
'
;
export
const
activeFile
=
state
=>
state
.
openFiles
.
find
(
file
=>
file
.
active
)
||
null
;
...
...
@@ -59,28 +60,19 @@ export const getChangedFile = state => path => state.changedFiles.find(f => f.pa
export
const
getStagedFile
=
state
=>
path
=>
state
.
stagedFiles
.
find
(
f
=>
f
.
path
===
path
);
export
const
getChangesInFolder
=
state
=>
path
=>
{
const
filePathMatches
=
f
=>
f
.
path
.
replace
(
new
RegExp
(
`/
${
f
.
name
}
$`
),
''
).
indexOf
(
path
)
===
0
;
const
changedFilesCount
=
state
.
changedFiles
.
filter
(
f
=>
filePathMatches
(
f
)).
length
;
const
changedFilesCount
=
state
.
changedFiles
.
filter
(
f
=>
filePathMatches
(
f
,
path
)).
length
;
const
stagedFilesCount
=
state
.
stagedFiles
.
filter
(
f
=>
filePathMatches
(
f
)
&&
!
getChangedFile
(
state
,
f
.
path
),
f
=>
filePathMatches
(
f
,
path
)
&&
!
getChangedFile
(
state
)(
f
.
path
),
).
length
;
return
changedFilesCount
+
stagedFilesCount
;
};
export
const
getUnstagedFilesCountForPath
=
state
=>
path
=>
{
const
filePathMatches
=
f
=>
f
.
path
.
replace
(
new
RegExp
(
`/
${
f
.
name
}
$`
),
''
).
indexOf
(
path
)
===
0
;
const
changedFilesCount
=
state
.
changedFiles
.
filter
(
f
=>
filePathMatches
(
f
)).
length
;
export
const
getUnstagedFilesCountForPath
=
state
=>
path
=>
getChangesCountForState
(
state
.
changesFiles
,
path
);
return
changedFilesCount
;
};
export
const
getStagedFilesCountForPath
=
state
=>
path
=>
{
const
filePathMatches
=
f
=>
f
.
path
.
replace
(
new
RegExp
(
`/
${
f
.
name
}
$`
),
''
).
indexOf
(
path
)
===
0
;
const
stagedFilesCount
=
state
.
stagedFiles
.
filter
(
f
=>
filePathMatches
(
f
)).
length
;
return
stagedFilesCount
;
};
export
const
getStagedFilesCountForPath
=
state
=>
path
=>
getChangesCountForState
(
state
.
stagedFiles
,
path
);
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export
default
()
=>
{};
app/assets/javascripts/ide/stores/utils.js
View file @
55b91d94
...
...
@@ -137,3 +137,9 @@ export const sortTree = sortedTree =>
}),
)
.
sort
(
sortTreesByTypeAndName
);
export
const
filePathMatches
=
(
f
,
path
)
=>
f
.
path
.
replace
(
new
RegExp
(
`
${
f
.
name
}
$`
),
''
).
indexOf
(
`
${
path
}
/`
)
===
0
;
export
const
getChangesCountForState
=
(
state
,
path
)
=>
state
.
stagedFiles
.
filter
(
f
=>
filePathMatches
(
f
,
path
)).
length
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment