Composer requiring github repository fork branch still checks all tags - github

Short question: How can I make composer require my branch from my fork without checking all tags?
Long question:
I want composer to require a specific branch that I created of a fork I created from twig.
My assumption was, that, when defined correctly, composer directly requires the branch.
Instead first it checks all the tags and after that it loads the branch.
I don't want composer to check the tags, I just want to use the branch.
Is this the correct behaviour or am I requiring the branch incorreclty?
My fork would be github.com/myfork/Twig
My branch would be mybranchname
This is my composer.json
{
"require": {
"twig/twig": "dev-mybranchname"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/myfork/Twig"
}
]
...
...

This is the correct behavior. Composer checks for all tags first before it could get to your branch name.
You can check if your code is fetched from the right repository by checking your composer.lock
Your composer.lock should be like this.
{
"name": "twig/twig",
"version": "dev-mybranchname",
"source": {
"type": "git",
"url": "https://github.com/myfork/Twig",
"reference": <your_revision_number>
},
...
}

Related

Seeks 'commentsResolvedState' API proposal, but it doesn't exist

[warning] Via 'product.json#extensionEnabledApiProposals' extension
'github.vscode-pull-request-github' wants API proposal
'commentsResolvedState' but that proposal DOES NOT EXIST. Likely, the
proposal has been finalized (check 'vscode.d.ts') or was abandoned.
I don't know what is this error msgs mean is it a bug on the current version of vscode 1.75.1?
I don't know why it's called extension even though I don't install any extension named github.vscode-pull-request-github
also I tried to (check 'vscode.d.ts') in my laptop. I dont find any file of it, there's only vscode.d. Well My code and project still works find but this error msg always appear every time I opened my vs code and kind of annoying to see. I use windows 11
This is what I found on github:
https://github.com/microsoft/vscode-pull-request-github/pull/4447/commits/f36acaff7b81f077db18e74a7c673cf249eba996
I tried to put the code in setting.json but it seems doesn't work. this is the code:
{
"name": "vscode-pull-request-github",
"displayName": "%displayName%",
"description": "%description%",
"icon": "resources/icons/github_logo.png",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-pull-request-github"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-pull-request-github/issues"
},
"enabledApiProposals": [
"tokenInformation",
"contribShareMenu",
"treeItemCheckbox",
"contribCommentPeekContext",

How to get a list of submodules through github API?

I'm trying to get a list of submodules of a repository through GitHub API. After reading Github API docs, I did the following things: In Order to access the submodules of the Jquery, I use the following link to get a list of submodules, however, I cannot see any submodules from it. Could anyone please tell me what field should I use to get a list of submodules of a repository from GitHub API?
You can get the list of git submodules using Github GraphQL API v4 with the submodules connection property :
{
repository(owner: "bertrandmartel", name: "javacard-tutorial") {
submodules(first: 100) {
nodes {
name
path
}
}
}
}
Try this in the explorer
Output :
{
"data": {
"repository": {
"submodules": {
"nodes": [
{
"name": "oracle_javacard_sdks",
"path": "oracle_javacard_sdks"
}
]
}
}
}
}
Note that this will give only submodules on default branch's HEAD, from the documentation :
Returns a list of all submodules in this repository parsed from the .gitmodules file as of the default branch's HEAD commit.
Note that the jquery repository doesn't have any git submodules in its default branch's HEAD (and I don't see any in its other branches)
If you use v3 REST API you can
Get the HEAD commit SHA of the branch.
Use the returned commit SHA as the tree_sha to get tree. GET /repos/{owner}/{repo}/git/trees/{tree_sha}
Iterate the returned tree object for entry that has mode 160000 (submodule)

How can I get the user name of committer in each commit in a project in Git?

I am trying to make analysis between issues and commits of a project in git.
I am getting the name and email of the committer and author from git using the command below:
git log --pretty="%an %ae %cn %ce"
I am using 'curl -i "https://api.github.com/repos/<repo-owner>/<repo-name>/issues"' to download the issues. This returns the username[login name] for each issue not the name of the user as it is in the git log report:
{ "url": "https://api.github.com/repos/<repo-owner>/<repo-name>/issues/17625",
"node_id": "MDExOlB1bGxSZXF1ZXN0NTA5NDYyMjgz",
"number": 17625,
"title": "......",
"user": {
**"login": "xxxxxx",**
"id": 43045863,
....
"type": "User",
},
I check if the issue and commit has been made by the same user. Since I cannot get the username of committer, I cannot relate them. Is there a way to get the username of each commit on a project in git?

Can you read the properties of an artifact without downloading it?

I'm developing a release pipeline where I would like to do some analysis on a given artifact. I will not use the artifact itself for anything later, I'm only interested in reading certain properties such as version number. I, therefore, think that it is unnecessary to download an artifact that I won't do any changes to or to publish. From my point of view, the most time and resource-efficient way would be to not have to download the artifact, but I'm not sure if this is possible. Or are there workarounds, where you can download a "lite" version of the artifact? I'm planning on using a task for this.
If you want to get metadata for your build/pipeline artifact, you can't do this as there is no such thing. You can call this endpoint:
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/6179/artifacts?api-version=6.1-preview.5
but you will only get something like this:
{
"count": 1,
"value": [
{
"id": 1095,
"name": "drop",
"source": "12f1170f-54f2-53f3-20dd-22fc7dff55f9",
"resource": {
"type": "Container",
"data": "#/6799617/drop",
"properties": {
"localpath": "D:\\a\\1\\a",
"artifactsize": "1330651"
},
"url": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/6179/artifacts?artifactName=drop&api-version=6.1-preview.5",
"downloadUrl": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/6179/artifacts?artifactName=drop&api-version=6.1-preview.5&%24format=zip"
}
}
]
}
If you want to get details of you package in Azure Artifact, which is a feed, you have some option in REST API. For instance: Artifact Details - Get Package Version

Yii2 fork: dev-custom exists as yiisoft/yii2 but these are rejected by your constraint

I'm trying to use my forked version of yiisoft/yii2 in an installation of yii2-app-advanced.
I've followed this wiki.
I have created a branch named custom and pushed it to my yii2 fork.
In the composer.json of my fork I have the following (does it matter?):
...
"extra": {
"branch-alias": {
"dev-custom": "2.0.x-dev"
}
...
Then in my yii2-app-advanced installation I have the following composer.json:
{
"name": "yiisoft/yii2-app-advanced",
...
"minimum-stability": "stable",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/david-it/yii2"
}
],
"require": {
"php": ">=5.6.0",
"yiisoft/yii2": "dev-custom",
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
"yiisoft/yii2-bootstrap4": "~2.0.6"
},
...
}
When I run composer update I get the following error:
Problem 1
- The requested package yiisoft/yii2 dev-custom exists as yiisoft/yii2[2.0.0, 2.0.0-alpha, 2.0.0-beta, 2.0.0-rc, 2.0.1, 2.0.10, 2.0.11, 2.0.11.1, 2.0.11.2, 2.0.12, 2.0.12.1, 2.0.12.2, 2.0.13, 2.0.13.1, 2.0.13.2, 2.0.13.3, 2.0.14, 2.0.14.1, 2.0.14.2, 2.0.15, 2.0.15.1, 2.0.16, 2.0.16.1, 2.0.17, 2.0.18, 2.0.19, 2.0.2, 2.0.20, 2.0.21, 2.0.22, 2.0.23, 2.0.24, 2.0.25, 2.0.26, 2.0.27, 2.0.28, 2.0.29, 2.0.3, 2.0.30, 2.0.31, 2.0.32, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.x-dev, 3.0.x-dev, dev-master, 2.0.x-dev] but these are rejected by your constraint.
The command composer why-not yiisoft/yii2 dev-custom (if it is any useful here) shows this:
yiisoft/yii2-bootstrap4 2.0.8 requires yiisoft/yii2 (~2.0)
yiisoft/yii2-debug 2.1.13 requires yiisoft/yii2 (~2.0.13)
yiisoft/yii2-faker 2.0.4 requires yiisoft/yii2 (~2.0.0)
yiisoft/yii2-gii 2.1.4 requires yiisoft/yii2 (~2.0.14)
yiisoft/yii2-swiftmailer 2.1.2 requires yiisoft/yii2 (>=2.0.4)
I'm not sure what I am missing. I've looked around including this and this questions but with no luck.
EDIT 1
Composer 1.9.3 (2020-02-04 12:58:49) with PHP 7.2.24-0ubuntu0.18.04.3 on Linux / 4.15.0-91-generic
EDIT 2
Selecting dev-master as required works but the original files are downloaded (not the ones in the fork).
"require": {
...
"yiisoft/yii2": "dev-master",
...
}
I also tried all the tips from this answer with no luck.
At the moment, you have the custom branch. You need to create a branch named dev-custom in this situation, use the same branch name in require section of your composer.json file.
Your custom branch name must be prefixed with dev-.
After long hours of trial-and-error I've found two working solutions.
Solution 1 (With the help of Yii2 forum)
The branch apparently is considered "unstable", so you need to specify #dev to make composer work fine:
"require": {
...
"yiisoft/yii2": "dev-master#dev",
...
}
Solution 2
In the composer.json of my fork I've added an alias pointing to the branch:
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev",
"dev-custom": "2.0.n-dev"
}
}
Where n is just number (it should be unique among the versions available, I guess).
Then in the composer.json of my project I used "yiisoft/yii2": "2.0.n.x-dev".
I'm not quite sure why I have to use "2.0.n.x-dev" instead of "2.0.n-dev". A possible explanation is here.