The Cloud Repositories feature of the Google Cloud Platform includes several built-in tools for helping you browse, edit and troubleshoot the source code that you upload to your project's Git repository.
Source code browsing
After you've pushed source code to the Cloud Repository, you can view its contents in the Cloud Developers Console:
- Open your project in the Cloud Developers Console .
- Select SOURCE CODE > Browse in the left-hand navigation panel.
- Click on the file or directory you want to view.
You can see the latest commit, commit time, and author for each file or directory. In addition, you can modify that file or directory. You can also browse files and directories using the breadcrumbs above the file or directory listing.
By default, the Cloud Console displays the master branch of the repository, but you can switch branches easily with the button labeled with the current branch.
You can compare the current version of a file with a previous version by clicking the Diff button above the file contents, and selecting the version to compare against. The version you selected will appear on the left, so you can compare it to current version on the right. To turn file diff off, click Close diff .
Deploying a quick fix instantly
To make it easier to fix simple bugs, we've enabled single-file source editing directly from the Cloud Developers Console when you are viewing a file at the most current repository state ("head").
To edit a file:
- Browse to the file you wish to edit.
- Click Edit .
- Make the edits you wish to the file contents.
- Click Commit .
- Enter your commit message.
- Click Commit and deploy .
Making an edit and committing the change will trigger the Release Pipeline , if any, associated with your project. If you wish to discard your changes, you can click Cancel while editing the file.
Linking logs to source
For Java, Python and PHP applications running on Google App Engine, you can quickly jump from stack traces in Logs Viewer to the line of source the stack trace refers to.
To enable logs to source linking:
-
Push the latest version of your source code to your project's Cloud Repository.
-
Deploy your application to Google App Engine. If you have a release pipeline or Push-to-deploy configured, no manual deployment step is necessary.
As long as the Cloud Repository contains the latest version of the files you have deployed, you can browse from stack traces to source files regardless of how you deployed.
To use logs to source linking:
- Open your project in the Cloud Developers Console.
- Select COMPUTE > APP ENGINE > Logs from the left-hand navigation panel.
- Find a stack trace in your logs.
- From the stack trace, click the linked file and line number to jump to that file and line number.
Viewing a commit
Besides source code, you can also view the full contents of any
particular commit in your repository. Whenever you see a commit hash
(i.e.
1081abb19876
), you can click on it to view the details of
the commit. In the file or history view, you can also click the commit
message to see its details.
When viewing a commit, you can see each of the files modified as a part of that commit with code changes highlighted. If there are a larger number of modified files, some changed content may be collapsed by default.
You can click the icon next to the file name to expand or collapse the changed content. Click the icon next to the number of changed files at the top of the commit's file list to expand or collapse all the files at once.
You can also click View source at this commit to view the state of the repository at the displayed commit level.
Viewing commit history
Click History to view commit history from any branch, file or directory view. Click Source to return to the source view.