Рубрики

create

Which tones merged create black?

You now have a bitbucket pipeline that will automatically format Python code with black whenever your developers create a pull request or push new commits to it. It will avoid infinite bitbucket pipeline builds, it will detect if there are changes before committing.


Adjust color and tone with Levels and Curves eyedroppers

Keep in mind that using the eyedroppers undoes any previous adjustment you made in Levels or Curves. If you plan to use the eyedroppers, it’s best to use them first and then fine-tune your adjustments with the Levels sliders or Curves points.

Apply a Curves or Levels adjustment.

  • Double-click the Set Black Point eyedropper tool to set the black point.
  • Double-click the Set White Point eyedropper tool to set the white point.
  • To set the black point value to pure black, type 0 for R, G, and B.
  • To set the white point value to pure white, type 255 for R, G, and B.
  • To specify a shade of gray for either the black or white point, type identical values (between 0 and 255) for R, G, and B. The lower the values, the darker the gray. The higher the values, the lighter the gray.
  • With the Set Black Point eyedropper, click an image area that represents the black point (area with the lowest tonal values).
  • With the Set White Point eyedropper, click an image area that represents the white point (area with the lightest tonal values).

Color correct using the eyedroppers

You can use the eyedroppers in the Levels or Curves adjustment to correct a color cast such as an unwanted tint from an excess of color (red, green, blue, or cyan, magenta, yellow). It’s easier to color-balance an image by first identifying an area that you want to be neutral and then removing the color cast from that area. Depending on the image, you can use one or all three of the eyedroppers. The Set Gray Point eyedropper works best on images that don’t require large adjustments and have easily identified neutrals.

Keep in mind that using the eyedroppers undoes any previous adjustment you made in Levels or Curves. If you plan to use the eyedroppers, it’s best to use them first and then fine-tune your adjustments with the Levels sliders or Curves points.

Note:

The eyedropper tool that sets the gray point is used primarily for color correction and is unavailable when you work with grayscale images.

Before applying an adjustment, identify an area in the image that you want to be neutral gray. For example, a paved road.

Note:
Use a color sampler to mark a neutral area so that you can click it with an eyedropper later.
Click the Levels or Curves icon in the Adjustments panel.

In the Properties panel, double-click the Set Gray Point tool .

In the Adobe Color Picker, verify that the currently selected color has identical R, G, and B values for a neutral gray (for example, 128,128,128). If necessary, type the identical values for R, G, and B. Photoshop asks whether you want to save the new target color as a default.

With the Set Gray Point eyedropper tool, click the neutral area that you identified in Step 1. This should reset midtones and remove the color cast from the image.

1 Answer 1

Sorted by: Reset to default

Ok, after much figuring out, I figured out a way. I’m not sure if this is the best way but it works. I’ve changed the goal for the Bitbucket Pipeline to beautify the code and commit the reformatted code whenever a pull request is created or updated instead.

This solution is inspired by:

  • “Automating pull request creation from one branch to another using javascript, bitbucket pipelines and bitbucket api” by Benedict Steven
  • “GitHub Actions: How to Automate Code Formatting in Pull Requests” by Peter Evans

Step 1: Create an OAuth2 Consumer

Adding OAuth Consumer on Bitbucket

  1. Go to “Workspace Settings”
  2. Under category “Apps and Features”, click “OAuth consumers”
  3. Click “Add consumer”, fill out necessary information. Makes sure to add permission to “read” and “write” for Pull Requests permission category. Also, “Callback URL” can’t be empty, I used https://google.com .
  4. Click “Save”
  5. Your new OAuth consumer will have a Key and Secret generated

Adding Repository variable using the key and secret of the OAuth Consumer

  1. Go to the repository that will have the Bitbucket Pipeline setup
  2. Click “Repository settings”
  3. Under category “Pipelines”, click “Repository variables”
  4. Add a new variable with name being BB_AUTH_STRING and value being a string of format Key:Secret (see picture), using the key and secret of the OAuth consumer we created earlier
  5. Make sure to fill the checkbox “Secured” before clicking “Add”

Step 3: Setup your Bitbucket Pipeline YML

The bitbucket-pipelines.yml I’ve settled on currently is the following:

image: python:3.10 pipelines: pull-requests: '**': - step: name: Commit if there are changed files script: - apt-get update - apt-get -y install curl jq - pip install black - black -l 100 . - modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) # BB_AUTH_STRING is a "Repository Variable", # it's value is a string of the format "Key:Secret" # with "Key" and "Secret" being the key and secret of a OAuth2 Workspace Consumer - > if [ "$modified" = "false" ]; then exit 0; else export BB_TOKEN=$(curl -s -S -f -X POST -u "$"  https://bitbucket.org/site/oauth2/access_token  -d grant_type=client_credentials -d scopes="repository" | jq --raw-output '.access_token') ; git config --global user.name 'Automatic Linter'; git config --global user.email '[email protected]'; git remote set-url origin "https://x-token-auth:[email protected]/vietthan/myrepositoryname.git"; git add -A; git commit -m "[skip ci] automatic linter"; git push; fi condition: changesets: includePaths: - "**" 

This pipeline will only run whenever a Pull-Request is created and whenever new commits are made to the Pull Request.

The pipeline will install curl and jq .

The pipeline will install black .

The pipeline will then run black -l 100 .

If no files were modified, the pipeline will exit.

  1. It will use BB_AUTH_STRING to get a temporary access token stored in BB_TOKEN .
  2. It will set the git configuration for name, email
  3. It will set the git remote path+access token, I have this pointed to my intending repository.
  4. It will add all changed files, make a commit with [skip ci] in the commit head message to skip the pipeline when this commit is push
  5. Push the commit

Post-merge pipeline status

When a merge request is merged, you can see the post-merge pipeline status of the branch the merge request was merged into. For example, when a merge request is merged into the default branch and then triggers a deployment to the staging environment.

Ongoing deployments are shown, and the state (deploying or deployed) for environments. If it’s the first time the branch is deployed, the link returns a 404 error until done. During the deployment, the stop button is disabled. If the pipeline fails to deploy, the deployment information is hidden.

Merge request pipeline

Set auto-merge

Set a merge request that looks ready to merge to merge automatically when CI pipeline succeeds.

If you configured Review Apps for your project, you can preview the changes submitted to a feature branch through a merge request on a per-branch basis. You don’t need to check out the branch, install, and preview locally. All your changes are available to preview by anyone with the Review Apps link.

With GitLab Route Maps set, the merge request widget takes you directly to the pages changed, making it easier and faster to preview proposed modifications.

License compliance

If you have configured License Compliance for your project, then you can view a list of licenses that are detected for your project’s dependencies.

Merge request pipeline

Colin Wynn
the authorColin Wynn

Leave a Reply