Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
9958558b
Commit
9958558b
authored
3 years ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
fix
parent
df3de0d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/communication/website/git_file.rb
+2
-2
2 additions, 2 deletions
app/models/communication/website/git_file.rb
app/models/concerns/with_git.rb
+12
-14
12 additions, 14 deletions
app/models/concerns/with_git.rb
app/services/git/repository.rb
+2
-2
2 additions, 2 deletions
app/services/git/repository.rb
with
16 additions
and
18 deletions
app/models/communication/website/git_file.rb
+
2
−
2
View file @
9958558b
...
...
@@ -59,13 +59,13 @@ class Communication::Website::GitFile < ApplicationRecord
end
def
path
about
.
send
"git_path_
#{
identifier
}
"
@path
||=
about
.
send
"git_path_
#{
identifier
}
"
end
def
sha
# Git SHA-1 is calculated from the String "blob <length>\x00<contents>"
# Source: https://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html
OpenSSL
::
Digest
::
SHA1
.
hexdigest
"blob
#{
to_s
.
bytesize
}
\x00
#{
to_s
}
"
@sha
||=
OpenSSL
::
Digest
::
SHA1
.
hexdigest
"blob
#{
to_s
.
bytesize
}
\x00
#{
to_s
}
"
end
def
to_s
...
...
This diff is collapsed.
Click to expand it.
app/models/concerns/with_git.rb
+
12
−
14
View file @
9958558b
...
...
@@ -8,7 +8,6 @@ module WithGit
dependent: :destroy
end
# Needs override
def
git_path_static
raise
NotImplementedError
end
...
...
@@ -34,39 +33,38 @@ module WithGit
def
destroy_and_sync
destroy_from_git
destroy
true
end
def
destroy_from
_git
websites_
with_fallback
.
each
do
|
website
|
def
sync_with
_git
websites_
for_self
.
each
do
|
website
|
identifiers
(
website:
website
).
each
do
|
identifier
|
Communication
::
Website
::
GitFile
.
sync
website
,
self
,
identifier
,
destroy:
true
dependencies
=
send
"git_
destroy_
dependencies_
#{
identifier
}
"
Communication
::
Website
::
GitFile
.
sync
website
,
self
,
identifier
dependencies
=
send
"git_dependencies_
#{
identifier
}
"
dependencies
.
each
do
|
object
|
Communication
::
Website
::
GitFile
.
sync
website
,
object
,
identifier
,
destroy:
true
Communication
::
Website
::
GitFile
.
sync
website
,
object
,
identifier
end
end
website
.
git_repository
.
sync!
end
end
handle_asynchronously
:sync_with_git
def
sync_with
_git
websites_
with_fallback
.
each
do
|
website
|
def
destroy_from
_git
websites_
for_self
.
each
do
|
website
|
identifiers
(
website:
website
).
each
do
|
identifier
|
Communication
::
Website
::
GitFile
.
sync
website
,
self
,
identifier
dependencies
=
send
"git_dependencies_
#{
identifier
}
"
Communication
::
Website
::
GitFile
.
sync
website
,
self
,
identifier
,
destroy:
true
dependencies
=
send
"git_
destroy_
dependencies_
#{
identifier
}
"
dependencies
.
each
do
|
object
|
Communication
::
Website
::
GitFile
.
sync
website
,
object
,
identifier
Communication
::
Website
::
GitFile
.
sync
website
,
object
,
identifier
,
destroy:
true
end
end
website
.
git_repository
.
sync!
end
end
handle_asynchronously
:sync_with_git
protected
def
websites_
with_fallback
def
websites_
for_self
if
is_a?
Communication
::
Website
[
self
]
elsif
respond_to?
(
:websites
)
...
...
This diff is collapsed.
Click to expand it.
app/services/git/repository.rb
+
2
−
2
View file @
9958558b
...
...
@@ -25,7 +25,7 @@ class Git::Repository
protected
#
TODO
add gitlab
#
Enhancement
add gitlab
def
provider
@provider
||=
Git
::
Providers
::
Github
.
new
(
website
&
.
access_token
,
website
&
.
repository
)
end
...
...
@@ -48,7 +48,7 @@ class Git::Repository
def
mark_as_synced
git_files
.
each
do
|
git_file
|
git_file
.
update
_columns
previous_path:
git_file
.
path
,
previous_sha:
git_file
.
sha
git_file
.
update
previous_path:
git_file
.
path
,
previous_sha:
git_file
.
sha
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment