Repository: oppia/oppia

Issue:
[BUG]: Branch name and commit should only show up in prod mode
### Describe the bug

Branch name and commit ID is shown in the about page footer section. This should only show up in prod mode.

Update the code such that, when building, the relevant variables are updated only in the case of prod build. If it is not a prod build, use empty string.

### Steps To Reproduce

1. Go to the footer section of the about page in DEV mode.
2. See error

### Expected Behavior

Show branch name and commit ID in the about page footer section only in prod mode.


### Screenshots/Videos

_No response_

### What device are you using?

_No response_

### Operating System

_No response_

### What browsers are you seeing the problem on?

_No response_

### Browser version

_No response_

### Additional context

_No response_

### Tips for developers

Before tackling the bug, please use `git bisect` (see https://git-scm.com/docs/git-bisect)
to investigate which PR caused it (you only need to go back as far as
commit https://github.com/oppia/oppia/commits/9a334e9).
If you find the PR, leave a comment on this issue pointing to it, or
just say that it happened before commit 9a334e9 if you could reproduce
it there. This will help us fix the issue by reverting the faulty PR.

Also, if this is your first issue, please make sure to follow
https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue
and https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#setting-things-up
before claiming it. Thanks!

[BUG]: Branch name and commit should only show up in prod mode
### Describe the bug

Branch name and commit ID is shown in the about page footer section. This should only show up in prod mode.

Update the code such that, when building, the relevant variables are updated only in the case of prod build. If it is not a prod build, use empty string.

### Steps To Reproduce

1. Go to the footer section of the about page in DEV mode.
2. See error

### Expected Behavior

Show branch name and commit ID in the about page footer section only in prod mode.


### Screenshots/Videos

_No response_

### What device are you using?

_No response_

### Operating System

_No response_

### What browsers are you seeing the problem on?

_No response_

### Browser version

_No response_

### Additional context

_No response_

### Tips for developers

Before tackling the bug, please use `git bisect` (see https://git-scm.com/docs/git-bisect)
to investigate which PR caused it (you only need to go back as far as
commit https://github.com/oppia/oppia/commits/9a334e9).
If you find the PR, leave a comment on this issue pointing to it, or
just say that it happened before commit 9a334e9 if you could reproduce
it there. This will help us fix the issue by reverting the faulty PR.

Also, if this is your first issue, please make sure to follow
https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#choosing-a-good-first-issue
and https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#setting-things-up
before claiming it. Thanks!



Discussion:

Resolving patch:
diff --git a/scripts/common.py b/scripts/common.py
--- a/scripts/common.py
+++ b/scripts/common.py
@@ -982,39 +982,40 @@ def modify_constants(
     if feconf.OPPIA_IS_DOCKERIZED:
         return
 
-    branch_name_variable = (
-        '"BRANCH_NAME": "%s"'
-        % (
-            subprocess.check_output(
-                ['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
-                encoding='utf-8'
-            ).strip().split('\n', maxsplit=1)[0]
-            if version_info_must_be_set else ''
+    if prod_env or version_info_must_be_set is False:
+        branch_name_variable = (
+            '"BRANCH_NAME": "%s"'
+            % (
+                subprocess.check_output(
+                    ['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
+                    encoding='utf-8'
+                ).strip().split('\n', maxsplit=1)[0]
+                if version_info_must_be_set else ''
+            )
+        )
+        inplace_replace_file(
+            CONSTANTS_FILE_PATH,
+            r'"BRANCH_NAME": ".*"',
+            branch_name_variable,
+            expected_number_of_replacements=1
         )
-    )
-    inplace_replace_file(
-        CONSTANTS_FILE_PATH,
-        r'"BRANCH_NAME": ".*"',
-        branch_name_variable,
-        expected_number_of_replacements=1
-    )
 
-    short_commit_hash_variable = (
-        '"SHORT_COMMIT_HASH": "%s"'
-        % (
-            subprocess.check_output(
-                ['git', 'rev-parse', '--short', 'HEAD'],
-                encoding='utf-8'
-            ).strip().split('\n', maxsplit=1)[0]
-            if version_info_must_be_set else ''
+        short_commit_hash_variable = (
+            '"SHORT_COMMIT_HASH": "%s"'
+            % (
+                subprocess.check_output(
+                    ['git', 'rev-parse', '--short', 'HEAD'],
+                    encoding='utf-8'
+                ).strip().split('\n', maxsplit=1)[0]
+                if version_info_must_be_set else ''
+            )
+        )
+        inplace_replace_file(
+            CONSTANTS_FILE_PATH,
+            r'"SHORT_COMMIT_HASH": ".*"',
+            short_commit_hash_variable,
+            expected_number_of_replacements=1
         )
-    )
-    inplace_replace_file(
-        CONSTANTS_FILE_PATH,
-        r'"SHORT_COMMIT_HASH": ".*"',
-        short_commit_hash_variable,
-        expected_number_of_replacements=1
-    )
 
 
 def is_oppia_server_already_running() -> bool:


Test patch: