Comments (5)
I'm unable to repro your issue, and you failed to include any verbose logs (either by copy/pasting the relevant section of your log file, or by re-running the command with -Verbose
) that would provide pointers into the issue that you're having.
For reference, this command works fine:
Get-GitHubRepositoryLanguage -OwnerName microsoft -RepositoryName powershellforgithub
returns:
PowerShell
----------
1446793
from powershellforgithub.
@HowardWolosky, thank you for looking at the question. It requires querying multiple repos. Here is more information.
PS C:\> Get-GitHubRepositoryLanguage -OwnerName microsoft -RepositoryName PowerShellForGitHub
PowerShell
----------
1446793
PS C:\> Get-GitHubRepositoryLanguage -OwnerName powershell -RepositoryName powershell
C# : 30816340
PowerShell : 5130858
Roff : 216538
Shell : 57893
Rich Text Format : 40664
HTML : 18166
XSLT : 14394
JavaScript : 8738
Dockerfile : 6482
Batchfile : 24
However, when the two commands are run sequentially or in a script, the output contains only language 'PowerShell' information.
PS C:\> Get-GitHubRepositoryLanguage -OwnerName microsoft -RepositoryName PowerShellForGitHub -Verbose
>> Get-GitHubRepositoryLanguage -OwnerName powershell -RepositoryName powershell -Verbose
>>
VERBOSE: [0.16.1] Executing: Get-GitHubRepositoryLanguage -OwnerName "microsoft" -RepositoryName "PowerShellForGitHub" -Verbose:$true
VERBOSE: Getting languages for PowerShellForGitHub
VERBOSE: Accessing [Get] https://api.github.com/repos/microsoft/PowerShellForGitHub/languages [Timeout = 0)]
VERBOSE: HTTP/1.1 GET with 0-byte payload
VERBOSE: received 22-byte response of content type application/json
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubRepositoryLanguage].
VERBOSE: [0.16.1] Executing: Get-GitHubRepositoryLanguage -OwnerName "powershell" -RepositoryName "powershell" -Verbose:$true
VERBOSE: Getting languages for powershell
VERBOSE: Accessing [Get] https://api.github.com/repos/powershell/powershell/languages [Timeout = 0)]
VERBOSE: HTTP/1.1 GET with 0-byte payload
VERBOSE: received 166-byte response of content type application/json
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubRepositoryLanguage].
PowerShell
----------
1446793
5130858
PS C:\> cat $Env:USERPROFILE/bin/atest.ps1
Get-GitHubRepositoryLanguage -OwnerName microsoft -RepositoryName PowerShellForGitHub -Verbose
Get-GitHubRepositoryLanguage -OwnerName powershell -RepositoryName powershell -Verbose
PS C:\> & $Env:USERPROFILE/bin/atest.ps1
VERBOSE: [0.16.1] Executing: Get-GitHubRepositoryLanguage -OwnerName "microsoft" -RepositoryName "PowerShellForGitHub" -Verbose:$true
VERBOSE: Getting languages for PowerShellForGitHub
VERBOSE: Accessing [Get] https://api.github.com/repos/microsoft/PowerShellForGitHub/languages [Timeout = 0)]
VERBOSE: HTTP/1.1 GET with 0-byte payload
VERBOSE: received 22-byte response of content type application/json
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubRepositoryLanguage].
VERBOSE: [0.16.1] Executing: Get-GitHubRepositoryLanguage -OwnerName "powershell" -RepositoryName "powershell" -Verbose:$true
VERBOSE: Getting languages for powershell
VERBOSE: Accessing [Get] https://api.github.com/repos/powershell/powershell/languages [Timeout = 0)]
VERBOSE: HTTP/1.1 GET with 0-byte payload
VERBOSE: received 166-byte response of content type application/json
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubRepositoryLanguage].
PowerShell
----------
1446793
5130858
PS C:\> Get-GitHubRepositoryLanguage -OwnerName microsoft -RepositoryName PowerShellForGitHub | Get-Member
TypeName: GitHub.RepositoryLanguage
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
PowerShell NoteProperty long PowerShell=1446793
PS C:\> Get-GitHubRepositoryLanguage -OwnerName powershell -RepositoryName powershell | Get-Member
TypeName: GitHub.RepositoryLanguage
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Batchfile NoteProperty long Batchfile=24
C# NoteProperty long C#=30816340
Dockerfile NoteProperty long Dockerfile=6482
HTML NoteProperty long HTML=18166
JavaScript NoteProperty long JavaScript=8738
PowerShell NoteProperty long PowerShell=5130858
Rich Text Format NoteProperty long Rich Text Format=40664
Roff NoteProperty long Roff=216538
Shell NoteProperty long Shell=57893
XSLT NoteProperty long XSLT=14394
from powershellforgithub.
This is simply the nature of PowerShell ... nothing specific to this module.
This will produce the same result.
$a = Get-GitHubRepositoryLanguage -OwnerName microsoft -RepositoryName PowerShellForGitHub -Verbose
$b = Get-GitHubRepositoryLanguage -OwnerName powershell -RepositoryName powershell -Verbose
$a
>> $b
Or more simply:
$a = [PSCustomObject]@{'a' = 1}
$b = [PSCustomObject]@{'a' = 1; 'b' = 2; 'c' = 3 }
$a
>> $b
What are you trying to accomplish with that command? It's pretty ambiguous at the moment.
from powershellforgithub.
@HowardWolosky, I would like to produce a list of repos and the languages used. Something like:
RepoName Language Loc
-------- -------- ---
repo1 PowerShell 0858
repo2 C# 30816340
repo2 PowerShell 5130858
repo2 Roff 216538
repo2 Shell 57893
repo3 Rich Text Format 40664
repo3 HTML 18166
from powershellforgithub.
ConvertFrom-Json
converts a json string into a [PSCustomObject]
, and that's what PowerShellForGitHub is built on top of (as is almost any PowerShell module that interacts with a REST Api). The objects that come out of that Get-GitHubRepositoryLanguage
are not guaranteed to have the same properties however (both PowerShell and PowerShellForGitHub have a PowerShell
property, but PowerShell has a number of other ones as well). PowerShell doesn't know how to merge disparate [PSCustomObject]
s into a single table.
To achieve that list, you'll need to do post-processing of the data. Something like this:
$repos = @(
@{'owner' = 'PowerShell'; 'name' = 'PowerShell' },
@{'owner' = 'microsoft'; 'name' = 'PowerShellForGitHub' }
)
$repoLanguages = @()
foreach ($repo in $repos)
{
$result = Get-GitHubRepositoryLanguage -OwnerName $repo.owner -RepositoryName $repo.name
foreach ($lang in $result.PSObject.Properties.Name)
{
$repoLanguages += [PSCustomObject]@{
'owner' = $repo.owner
'repo' = $repo.name
'language' = $lang
'loc' = $result.$lang
}
}
}
# this will spit out a table that matches what you're looking for:
$repoLanguages
<#
owner repo language loc
----- ---- -------- ---
PowerShell PowerShell C# 30816340
PowerShell PowerShell PowerShell 5140070
PowerShell PowerShell Roff 216538
PowerShell PowerShell Shell 57893
PowerShell PowerShell Rich Text Format 40664
PowerShell PowerShell HTML 18166
PowerShell PowerShell XSLT 14394
PowerShell PowerShell JavaScript 8738
PowerShell PowerShell Dockerfile 6482
PowerShell PowerShell Batchfile 24
microsoft PowerShellForGitHub PowerShell 1446793
#>
from powershellforgithub.
Related Issues (20)
- API Coverage: Add Support for Deployment Environments
- Missing contributors from Get-GitHubRepositoryContributor
- Missing Org Role information from Get-GitHubOrganizationMember HOT 1
- Get-GitHubUser fails HOT 3
- PSProvider for GitHub
- Get-GitHubOrganizationMember does not use DefaultOwnerName
- GitHubRepositories: Unit Tests are Failing when Checking for `has_wiki` on Private Repositories
- Add support for authentication with JWT HOT 2
- API Coverage: Add Support for Codespaces HOT 1
- Exported functions not behaving correctly with -ErrorAction SilentlyContinue HOT 3
- Get-GitHubIssue commands different output
- Add additional filtering parameters to Get-GitHubPullRequest
- Reliance on BinaryFormatter breaks module with PowerShell 7.4.0-preview.4 HOT 5
- telemetry error HOT 3
- telemetry error HOT 1
- Powershell core on linux HOT 2
- Get-GithubRepository doesn't appear to honor ErrorAction inside a a try/catch HOT 1
- Encountered a problem while trying to record telemetry events
- When not specified, DisallowMergeCommit and other flags don't work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powershellforgithub.