Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P6251
add_minus_x.py
Active
Public
Actions
Authored by
Legoktm
on Nov 3 2017, 12:51 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F10579252: add_minus_x.py
Nov 3 2017, 12:51 AM
2017-11-03 00:51:00 (UTC+0)
Subscribers
None
#!/usr/bin/env python3
from
collections
import
OrderedDict
import
json
import
os
import
subprocess
import
sys
PKG
=
'mediawiki/minus-x'
GRR
=
'/home/km/.venvs/grr/bin/grr'
if
not
os
.
path
.
exists
(
'composer.json'
):
print
(
'Error: composer.json does not exist'
)
sys
.
exit
(
0
)
with
open
(
'composer.json'
,
'r'
)
as
f
:
j
=
json
.
load
(
f
,
object_pairs_hook
=
OrderedDict
)
if
'require-dev'
not
in
j
:
print
(
'Error: repo has no dev deps setup yet'
)
sys
.
exit
(
0
)
if
PKG
in
j
[
'require-dev'
]:
print
(
'Error: MinusX already setup'
)
sys
.
exit
(
0
)
j
[
'require-dev'
][
PKG
]
=
'0.2.0'
j
[
'scripts'
][
'test'
]
.
append
(
'minus-x check .'
)
if
'fix'
in
j
[
'scripts'
]:
if
isinstance
(
j
[
'scripts'
][
'fix'
],
list
):
j
[
'scripts'
][
'fix'
]
.
append
(
'minus-x fix .'
)
else
:
j
[
'scripts'
][
'fix'
]
=
[
j
[
'scripts'
][
'fix'
],
'minus-x fix .'
]
else
:
j
[
'scripts'
][
'fix'
]
=
[
'minus-x fix .'
]
with
open
(
'composer.json'
,
'w'
)
as
f
:
out
=
json
.
dumps
(
j
,
indent
=
'
\t
'
,
ensure_ascii
=
False
)
f
.
write
(
out
+
'
\n
'
)
print
(
'Updated composer.json'
)
subprocess
.
check_call
([
'composer'
,
'update'
])
subprocess
.
check_call
([
'composer'
,
'test'
])
subprocess
.
call
([
'git'
,
'diff'
])
subprocess
.
call
([
GRR
,
'init'
])
subprocess
.
check_call
([
'git'
,
'add'
,
'composer.json'
])
subprocess
.
check_call
([
'git'
,
'commit'
,
'-m'
,
'build: Adding MinusX'
])
subprocess
.
check_call
([
GRR
,
'--topic=MinusX'
])
Event Timeline
Legoktm
created this paste.
Nov 3 2017, 12:51 AM
2017-11-03 00:51:00 (UTC+0)
Legoktm
mentioned this in
T175794: Add MinusX to MediaWiki extensions and PHP library repos
.
Log In to Comment