Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
James C Bowden
mini-vc
Commits
fc7a7c2c
Commit
fc7a7c2c
authored
5 years ago
by
James C Bowden
Browse files
Options
Download
Email Patches
Plain Diff
debugging
parent
1c1d80b7
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.js
+40
-1
server.js
with
40 additions
and
1 deletion
+40
-1
server.js
View file @
fc7a7c2c
...
...
@@ -20,8 +20,8 @@ http.createServer((req, res) => {
}
// handle cases
if
(
req_obj
.
url
==
'
/new_repository
'
){
// make empty repo if dne
// check if name already exists
// if(repo_names.includes(req_obj.name)){
if
(
repos
.
has
(
req_obj
.
name
)){
throw
'
Repository already exists!
'
}
...
...
@@ -35,6 +35,7 @@ http.createServer((req, res) => {
}
}
else
if
(
req_obj
.
url
==
'
/fetch
'
){
// don't need to alter anything, just get newest commits.
let
obj
// check if name is actual repo
if
(
!
repos
.
has
(
req_obj
.
name
)){
...
...
@@ -70,9 +71,47 @@ http.createServer((req, res) => {
}
}
else
if
(
req_obj
.
url
==
'
/commit
'
){
//
let
obj
// check if name is actual repo
if
(
!
repos
.
has
(
req_obj
.
name
)){
throw
'
Repository does not exist.
'
}
else
{
// get json object
obj
=
async
()
=>
{
obj
=
await
JSON
.
parse
(
repos
[
req_obj
.
name
])
}
}
// check if head == pID
let
present
=
false
let
no_coms
=
true
if
(
req_obj
.
parentID
!=
null
){
no_coms
=
false
}
for
(
com
of
obj
.
commits
){
if
(
req_obj
.
parentID
==
com
.
id
){
present
=
true
break
}
}
if
(
!
present
&&
!
no_coms
){
throw
'
Most recent commit does not exist in repository.
'
}
else
{
let
head
=
obj_commits
[
obj_commits
.
length
-
1
]
if
(
head
==
req_obj
.
parentID
){
// do normally--add this to the commit list, change files by diff.
}
else
{
// merge
// try(mergefilediffs)
// catch(error)
// write errror
}
}
let
id
=
require
(
'
crypto
'
).
randomBytes
(
16
).
toString
(
'
hex
'
)
}
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help