Github branch name pattern - github

can i restrict barnch name in our pattern so all developers can follow predefined format of branch name?
I want to apply branch name pattern globally so when developer create branch and submit code , then branch name must first validate with our defined naming convention, if succeeded then it will pass to remote other show error message in local system
Thanks

Related

Is there a way to shorten the check name in GitHub PR?

This is the check name in Github using Github Actions.
It contains the workflow name + job id + step name + on condition.
Is it possible to make it shorter, as we have with apps? SonarCloud, for example, only has a single name.
Removing the name parameter only makes it worse since github will use the full filename (plus path) instead of a single friendly name.
You can customise that by defining run-name on top level of your workflow.
run-name: "SonarCloud Code Analysis"
You can read about it in docs here

How do I make a release pipeline in Azure DevOps that creates a GitHub release every time?

I get this warning when the pipeline runs:
Release will not be created as the tags for the target commit do not match with the given tag pattern.
Thing is, the Tag Pattern property of the GitHub release is blank; I'm not setting any particular tag pattern. How do I skip this warning so the release can be created every time the pipeline runs?
How do I make a release pipeline in Azure DevOps that creates a GitHub release every time?
I could reproduce this issue on my side, if I leave the Tag Pattern property of the GitHub release is blank.
That because this property is Required. Check the GitHub Release task:
Tag source (Required) Configure the tag to be used for release
creation. The 'Git tag' option automatically takes the tag which is
associated with this commit. Use the 'User specified tag' option in
case you want to manually provide a tag.
As the description above, the 'Git tag' option automatically takes the tag which is
associated with this commit.
So, if we leave that property Tag Pattern is blank, the value is null, but the commit id is not null, then you will get this error. Check my detailed build log:
To resolve this issue, we could give the Tag Pattern with the commit ID. Or you could use the another option User specified tag, then you can manually provide a tag, like release-v1.0.
As test, it works fine on my side.
Update:
but I want the pipeline to run every time someone pushes or merges code into the master branch; I don't want to have to specify a tag for each commit
If you do not want to have to specify a tag for each commit, you can use counter expressions in Variables, like:
variables:
MajorVersion: 1
MinorVersion: 0
InitialReleaseTagNumber: 1
IncrementReleaseTagNumber: $[counter(variables['InitialReleaseTagNumber'], 0)]
Then we set v$(MajorVersion).$(MinorVersion).$(IncrementReleaseTagNumber) following in the tag option:
So, the value of the tag will increase by 1 once the build runs.
Hope this helps.

How not to have 'version=GBmaster' in Azure DevOps links

Azure DevOps urls to files and to wiki entries contain &version=GBmaster and &wikiVersion=GBwikiMaster respectively.
Is it possible to configure DevOps not to append it?
Today I get:
https://myorg.visualstudio.com/MyProject/_git/MyRepo?path=%2Fsrc%2FMyFile.cs&version=GBmaster
https://dev.azure.com/rbtech/Redback/_wiki/wikis/MyOrg.wiki?pagePath=%2MyPage&pageId=204&wikiVersion=GBwikiMaster
I wish for:
https://myorg.visualstudio.com/MyProject/_git/MyRepo?path=%2Fsrc%2FMyFile.cs
https://dev.azure.com/rbtech/Redback/_wiki/wikis/MyOrg.wiki?pagePath=%2MyPage&pageId=204
This is the default behavior of AzureDevop basically &version/ &wikiversion is denoted which branch the code/wiki is showing in the UI. Even if you don't provide the Version AzureDevOps will automatically append it to indicate which branch is chosen.
Let's say in your repo you have multiple branches means like master/ develop then based on the branch you choose the &version will change automatically like &version=GBmaster or &version=GBdevelop if you don't provide the default branch will be appended in the query.
Is it possible to configure DevOps not to append it?
No, there isn't a way to configure it. It's the expected behavior as Jayendran described, it's a tag which marks the file version from which branch.
If you want to see the contents of the files without the &version=GBmaster, then you can try call the REST API : Items - Get
For example:
https://{organization}.visualstudio.com/{Project}/_apis/git/repositories/{Repository ID}/items?path=WAP/WAP.Tests/Properties/AssemblyInfo.cs

Is there a way to exclude specific branch names/patterns in GitHub branch protection?

I want to enable GitHub branch protection on all branches except those prefixed with "private_", for example. This way, we do not have to enable every new 'non private' branch as it is created.
I cannot find a way, using GitHub's pattern matching/globbing rules, to accomplish this. Something like a "/^private*/" rule would be ideal. Unfortunately, we do not enforce naming conventions, so a "common-prefix*" rule wouldn't help here.
Does anyone know of a way to do this, in the GUI branch protection rules, not via the API?
Thanks in advance!
Using **\** as the last branch protection rule applies the branch protection rules for all the branches which do not fall into any of the mentioned branch protection rules.
For example if you have these branches - users-1, users-2, releases-1, releases-2, temp-1, temp2, random
then, branch protections like the below would set:
users-* --> would cover users-1, users-2
releases-* --> would cover releases-1, releases-2
**\** --> would cover everything else temp-1, temp2, random
Protected branch rules use patterns from the fnmatch syntax.
They don't work as RegExp expressions, so it's not possible to apply a lookahead expression to match only branches that not start with private_.
What you can do is to apply a prefix for protected branches. For example, all branches named protected_ (or public_) would be the protected.
So you'd need the rule protected_*
Demo: https://repl.it/#herodrigues/LopsidedAwfulPortablesoftware

How to Capitalize the first letter of existing GitHub repository?

Situation is:
Currently, I have a repository name phimpme-iOS. I want to capitalize the first letter of the repository, Phimpme-iOS.
When I change the name in Settings > Options > Repository Name, it cannot be changed and it is showing -
The repository Phimpme-iOS already exists on this account
User names and repository names are case-insensitive at Github: phimpme-iOS is the same as Phimpme-iOS; that is, from Github PoV you're trying to rename the repo to an equivalent name.
Try a completely different name — xxx, for example — and then rename it once more to Phimpme-iOS.
Rename your repository to something completely different (e.g. "foo") and then name it back to the original name with the desired capitalization.