11#!/usr/bin/python
22
33import datetime
4- import os
5- import re
6- import subprocess
74import argparse
85import yaml
96
7+ from utils import write_yaml , shell_value , get_commit , get_branch
8+
109# branch and release information source
1110GIT_REMOTE = { 'upstream' : 'mongodb/docs' }
1211MANUAL_BRANCH = 'master'
1312PUBLISHED_BRANCHES = [ 'master' , 'v2.2' ] # PUBLISHED_BRANCHES **must** be ordered from latest to oldest release.
1413PUBLISHED_VERSIONS = [ '2.4' , '2.2' ]
14+
1515STABLE_RELEASE = PUBLISHED_VERSIONS [0 ]
1616UPCOMING_RELEASE = None
1717
18- def get_build_envs ():
19- s = (['build/' + branch + '/branch-source/' for branch in PUBLISHED_BRANCHES ] +
20- ['build/' + branch + '/branch-source-current/' for branch in PUBLISHED_BRANCHES ])
21- s .append ('build/' + branch + '/source/' )
22- return s
23-
24- def shell_value (args , path = None ):
25- if path is None :
26- path = os .getcwd ()
27-
28- if isinstance (args , str ):
29- r = re .compile ("\s+" )
30- args = r .split (args )
31-
32- p = subprocess .Popen (args , cwd = path , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
33- r = p .communicate ()
34-
35- return str (r [0 ].decode ().rstrip ())
36-
3718def get_manual_path ():
3819 branch = get_branch ()
3920
@@ -44,18 +25,6 @@ def get_manual_path():
4425
4526 return manual_path
4627
47- def get_commit (path = None ):
48- if path is None :
49- path = os .getcwd ()
50-
51- return shell_value ('git rev-parse --verify HEAD' , path )
52-
53- def get_branch (path = None ):
54- if path is None :
55- path = os .getcwd ()
56-
57- return shell_value ('git symbolic-ref HEAD' , path ).split ('/' )[2 ]
58-
5928def get_versions ():
6029 o = []
6130
@@ -85,8 +54,7 @@ def output_yaml(fn):
8554 'pdfs' : []
8655 }
8756
88- with open (fn , 'w' ) as f :
89- f .write (yaml .dump (o , default_flow_style = False ))
57+ write_yaml (o , fn )
9058
9159def render_paths (fn ):
9260 paths = {
@@ -101,8 +69,7 @@ def render_paths(fn):
10169 paths ['branch-staging' ] = paths ['public' ] + '/' + get_branch ()
10270
10371 if str (fn ).endswith ('yaml' ):
104- with open (fn , 'w' ) as f :
105- f .write (yaml .dump (paths , default_flow_style = False ))
72+ utils .write_yaml (paths , fn )
10673 elif fn == 'print' :
10774 print (yaml .dump (paths , default_flow_style = False ))
10875 else :
0 commit comments