Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma
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
Container Registry
Model registry
Operate
Environments
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
Alex Gleason
pleroma
Commits
a02f52d1
Commit
a02f52d1
authored
5 years ago
by
Ivan Tashkinov
Browse files
Options
Downloads
Patches
Plain Diff
[#1048] Resolved violations of SemVer version format. Refactoring.
parent
a565dbde
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mix.exs
+27
-21
27 additions, 21 deletions
mix.exs
with
27 additions
and
21 deletions
mix.exs
+
27
−
21
View file @
a02f52d1
...
...
@@ -174,10 +174,14 @@ defp aliases do
# Builds a version string made of:
# * the application version
# * a pre-release if ahead of the tag: the describe string (-count-commithash)
# * build info:
# * branch name
# * build metadata:
# * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
# * the mix environment if different than prod
defp
version
(
version
)
do
identifier_filter
=
~r/[^0-9a-z\-]+/i
# Pre-release version, denoted from patch version with a hyphen
{
git_tag
,
git_pre_release
}
=
with
{
tag
,
0
}
<-
System
.
cmd
(
"git"
,
[
"describe"
,
"--tags"
,
"--abbrev=0"
],
stderr_to_stdout:
true
),
...
...
@@ -198,6 +202,19 @@ defp version(version) do
)
end
# Branch name as pre-release version component, denoted with a dot
branch_name
=
with
{
branch_name
,
0
}
<-
System
.
cmd
(
"git"
,
[
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
]),
branch_name
<-
System
.
get_env
(
"PLEROMA_BUILD_BRANCH"
)
||
branch_name
,
true
<-
branch_name
!=
"master"
do
branch_name
=
branch_name
|>
String
.
trim
()
|>
String
.
replace
(
identifier_filter
,
"-"
)
"."
<>
branch_name
end
build_name
=
cond
do
name
=
Application
.
get_env
(
:pleroma
,
:build_name
)
->
name
...
...
@@ -206,37 +223,26 @@ defp version(version) do
end
env_name
=
if
Mix
.
env
()
!=
:prod
,
do
:
to_string
(
Mix
.
env
())
env_override
=
System
.
get_env
(
"PLEROMA_BUILD_ENV"
)
env_name
=
if
env_override
do
if
env_override
!=
"prod"
,
do
:
env_overrid
e
else
env_
nam
e
case
env_override
do
nil
->
env_nam
e
env_override
when
env_override
in
[
""
,
"prod"
]
->
nil
env_
override
->
env_overrid
e
end
build
=
# Build metadata, denoted with a plus sign
build_metadata
=
[
build_name
,
env_name
]
|>
Enum
.
filter
(
fn
string
->
string
&&
string
!=
""
end
)
|>
Enum
.
join
(
"
-
"
)
|>
Enum
.
join
(
"
.
"
)
|>
(
fn
""
->
nil
string
->
"+"
<>
string
string
->
"+"
<>
String
.
replace
(
string
,
identifier_filter
,
"-"
)
end
)
.
()
branch_name
=
with
{
branch_name
,
0
}
<-
System
.
cmd
(
"git"
,
[
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
]),
branch_name
<-
System
.
get_env
(
"PLEROMA_BUILD_BRANCH"
)
||
branch_name
,
true
<-
branch_name
!=
"master"
do
branch_name
=
String
.
trim
(
branch_name
)
|>
String
.
replace
(
~r/[^0-9a-z\-\.]+/i
,
"-"
)
"-"
<>
branch_name
end
[
version
,
git_pre_release
,
branch_name
,
build
]
[
version
,
git_pre_release
,
branch_name
,
build_metadata
]
|>
Enum
.
filter
(
fn
string
->
string
&&
string
!=
""
end
)
|>
Enum
.
join
()
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