Browse code

Merge "allow for soft updating of global-requirements"

Jenkins authored on 2014/10/30 04:08:03
Showing 2 changed files
... ...
@@ -1645,6 +1645,16 @@ function setup_develop {
1645 1645
     setup_package_with_req_sync $project_dir -e
1646 1646
 }
1647 1647
 
1648
+# determine if a project as specified by directory is in
1649
+# projects.txt. This will not be an exact match because we throw away
1650
+# the namespacing when we clone, but it should be good enough in all
1651
+# practical ways.
1652
+function is_in_projects_txt {
1653
+    local project_dir=$1
1654
+    local project_name=$(basename $project_dir)
1655
+    return grep "/$project_name\$" $REQUIREMENTS_DIR/projects.txt >/dev/null
1656
+}
1657
+
1648 1658
 # ``pip install -e`` the package, which processes the dependencies
1649 1659
 # using pip before running `setup.py develop`
1650 1660
 #
... ...
@@ -1663,8 +1673,19 @@ function setup_package_with_req_sync {
1663 1663
     local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed")
1664 1664
 
1665 1665
     if [[ $update_requirements != "changed" ]]; then
1666
-        (cd $REQUIREMENTS_DIR; \
1667
-            python update.py $project_dir)
1666
+        if [[ "$REQUIREMENTS_MODE" == "soft" ]]; then
1667
+            if is_in_projects_txt $project_dir; then
1668
+                (cd $REQUIREMENTS_DIR; \
1669
+                    python update.py $project_dir)
1670
+            else
1671
+                # soft update projects not found in requirements project.txt
1672
+                (cd $REQUIREMENTS_DIR; \
1673
+                    python update.py -s $project_dir)
1674
+            fi
1675
+        else
1676
+            (cd $REQUIREMENTS_DIR; \
1677
+                python update.py $project_dir)
1678
+        fi
1668 1679
     fi
1669 1680
 
1670 1681
     setup_package $project_dir $flags
... ...
@@ -116,6 +116,17 @@ DATABASE_QUERY_LOGGING=$(trueorfalse True $DATABASE_QUERY_LOGGING)
116 116
 # Zero disables timeouts
117 117
 GIT_TIMEOUT=${GIT_TIMEOUT:-0}
118 118
 
119
+# Requirements enforcing mode
120
+#
121
+# - strict (default) : ensure all project requirements files match
122
+#   what's in global requirements.
123
+#
124
+# - soft : enforce requirements on everything in
125
+#   requirements/projects.txt, but do soft updates on all other
126
+#   repositories (i.e. sync versions for requirements that are in g-r,
127
+#   but pass through any extras)
128
+REQUIREMENTS_MODE=${REQUIREMENTS_MODE:-strict}
129
+
119 130
 # Repositories
120 131
 # ------------
121 132