Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
devflow
Commits
e727d1ba
Commit
e727d1ba
authored
Jan 16, 2013
by
Christos Stavrakakis
Browse files
Add default debian branch
parent
1c3c6417
Changes
2
Hide whitespace changes
Inline
Side-by-side
devflow/autopkg.py
View file @
e727d1ba
...
...
@@ -34,11 +34,11 @@
import
git
import
os
import
sys
from
sh
import
mktemp
,
cd
,
rm
,
git_dch
,
python
from
optparse
import
OptionParser
from
collections
import
namedtuple
from
sh
import
mktemp
,
cd
,
rm
,
git_dch
,
python
from
devflow.versioning
import
(
get_python_version
,
debian_version_from_python_version
)
from
devflow
import
versioning
try
:
from
colors
import
red
,
green
...
...
@@ -51,6 +51,14 @@ print_green = lambda x: sys.stdout.write(green(x) + "\n")
AVAILABLE_MODES
=
[
"release"
,
"snapshot"
]
branch_type
=
namedtuple
(
"branch_type"
,
[
"default_debian_branch"
])
BRANCH_TYPES
=
{
"feature"
:
branch_type
(
"debian-develop"
),
"develop"
:
branch_type
(
"debian-develop"
),
"release"
:
branch_type
(
"debian-develop"
),
"master"
:
branch_type
(
"debian"
),
"hotfix"
:
branch_type
(
"debian"
)}
def
get_packages_to_build
(
toplevel_dir
):
conf_file
=
os
.
path
.
join
(
toplevel_dir
,
"autopkg.conf"
)
...
...
@@ -131,28 +139,34 @@ def main():
print
"Latest Reflog entry is %s"
%
reflog_hexsha
branch
=
repo
.
head
.
reference
.
name
if
branch
==
"master"
:
debian_branch
=
"debian"
else
:
debian_branch
=
"debian-"
+
branch
if
not
debian_branch
in
repo
.
references
:
# Branch does not exist!
if
"origin/"
+
debian_branch
in
repo
.
references
:
remote
=
"origin/"
+
debian_branch
else
:
remote
=
"origin/debian-develop"
repo
.
git
.
branch
(
"--track"
,
debian_branch
,
remote
)
brnorm
=
versioning
.
normalize_branch_name
(
branch
)
btypestr
=
versioning
.
get_branch_type
(
brnorm
)
debian_branch
=
"debian-"
+
brnorm
origin_debian
=
"origin/"
+
debian_branch
if
not
origin_debian
in
repo
.
references
:
# Get default debian branch
try
:
debian_branch
=
BRANCH_TYPES
[
btypestr
].
default_debian_branch
except
KeyError
:
allowed_branches
=
", "
.
join
(
x
for
x
in
BRANCH_TYPES
.
keys
())
raise
ValueError
(
"Malformed branch name '%s', cannot classify as one "
"of %s"
%
(
btypestr
,
allowed_branches
))
origin_debian
=
"origin/"
+
debian_branch
repo
.
git
.
branch
(
"--track"
,
debian_branch
,
origin_debian
)
print_green
(
"Created branch '%s' to track '%s'"
%
(
debian_branch
,
origin_debian
))
repo
.
git
.
checkout
(
debian_branch
)
print_green
(
"Changed to branch '%s'"
%
debian_branch
)
repo
.
git
.
merge
(
branch
)
print_green
(
"Merged branch '%s' into '%s'"
%
(
br
anch
,
debian_branch
))
print_green
(
"Merged branch '%s' into '%s'"
%
(
br
norm
,
debian_branch
))
cd
(
repo_dir
)
python_version
=
get_python_version
()
debian_version
=
debian_version_from_python_version
(
python_version
)
python_version
=
versioning
.
get_python_version
()
debian_version
=
versioning
.
debian_version_from_python_version
(
python_version
)
print_green
(
"The new debian version will be: '%s'"
%
debian_version
)
dch
=
git_dch
(
"--debian-branch=%s"
%
debian_branch
,
...
...
@@ -173,7 +187,7 @@ def main():
python_tag
=
python_version
debian_tag
=
"debian/"
+
python_tag
repo
.
git
.
tag
(
debian_tag
)
repo
.
git
.
tag
(
python_tag
,
br
anch
)
repo
.
git
.
tag
(
python_tag
,
br
norm
)
for
package
in
packages
:
# python setup.py should run in its directory
...
...
@@ -196,7 +210,7 @@ def main():
cd
(
repo_dir
)
os
.
system
(
"git-buildpackage --git-export-dir=%s --git-upstream-branch=%s"
" --git-debian-branch=%s --git-export=INDEX --git-ignore-new -sa"
%
(
build_dir
,
br
anch
,
debian_branch
))
%
(
build_dir
,
br
norm
,
debian_branch
))
if
not
options
.
keep_repo
:
print_green
(
"Removing cloned repo '%s'."
%
repo_dir
)
...
...
@@ -209,7 +223,7 @@ def main():
if
mode
==
"release"
:
TAG_MSG
=
"Tagged branch %s with tag %s
\n
"
print_green
(
TAG_MSG
%
(
br
anch
,
python_tag
))
print_green
(
TAG_MSG
%
(
br
norm
,
python_tag
))
print_green
(
TAG_MSG
%
(
debian_branch
,
debian_tag
))
UPDATE_MSG
=
"To update repository %s, go to %s, and run the"
\
...
...
devflow/versioning.py
View file @
e727d1ba
...
...
@@ -145,6 +145,26 @@ def build_mode():
return
mode
def
normalize_branch_name
(
branch_name
):
"""Normalize branch name by removing debian- if exists"""
brnorm
=
branch_name
if
brnorm
==
"debian"
:
brnorm
=
"debian-master"
# If it's a debian branch, ignore starting "debian-"
if
brnorm
.
startswith
(
"debian-"
):
brnorm
=
brnorm
.
replace
(
"debian-"
,
""
,
1
)
return
brnorm
def
get_branch_type
(
branch_name
):
"""Extract the type from a branch name"""
if
"-"
in
branch_name
:
btypestr
=
branch_name
.
split
(
"-"
)[
0
]
else
:
btypestr
=
branch_name
return
btypestr
def
python_version
(
base_version
,
vcs_info
,
mode
):
"""Generate a Python distribution version following devtools conventions.
...
...
@@ -265,18 +285,9 @@ def python_version(base_version, vcs_info, mode):
branch
=
vcs_info
.
branch
# If it's a debian branch, ignore starting "debian-"
brnorm
=
branch
if
brnorm
==
"debian"
:
brnorm
=
"debian-master"
if
brnorm
.
startswith
(
"debian-"
):
brnorm
=
brnorm
.
replace
(
"debian-"
,
""
,
1
)
# Sanity checks
if
"-"
in
brnorm
:
btypestr
=
brnorm
.
split
(
"-"
)[
0
]
else
:
btypestr
=
brnorm
brnorm
=
normalize_branch_name
(
branch
)
btypestr
=
get_branch_type
(
brnorm
)
try
:
btype
=
BRANCH_TYPES
[
btypestr
]
...
...
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