Kamis, 05 Oktober 2023

Only use a proxy for certain git urls/domains?

Problem

Is it possible to configure git to use a proxy only for specific domains?

I'd like to use our corporate proxy to access Github but leave it off for accessing our own internal git repos.

I'm using bower and it needs to require items both within our firewall and on github so I can't do this as a per project setting. It needs to be some kind of global configuration option. Any thoughts?

Solution and Answer

To add another possibility, you can define a proxy through the git config http.proxy.

git config --global http.proxy http://mydomain\\myusername:mypassword@myproxyserver:proxyport

But what is really neat is, starting git1.8.5 (October 2013), you can set http settings per url.

The "http.*" variables can now be specified per URL that the configuration applies.
For example,

[http]
   sslVerify = true
[http "https://weak.example.com/"]
   sslVerify = false

would flip http.sslVerify off only when talking to that specified site.


See commit d4770964d5:

$ git config --bool --get-urlmatch http.sslVerify https://good.example.com
true
$ git config --bool --get-urlmatch http.sslVerify https://weak.example.com
false

With only <section> specified, you can get a list of all variables in the section with their values that apply to the given URL. E.g

$ git config --get-urlmatch http https://weak.example.com
http.sslverify false

All the details are in commit 6a56993b:

http.<url>.*::

Any of the http.* options above can be applied selectively to some urls.
For a config key to match a URL, each element of the config key is compared to that of the URL, in the following order:

  • Scheme (e.g., https in https://example.com/).
  • Host/domain name (e.g., example.com in https://example.com/).
  • Port number (e.g., 8080 in http://example.com:8080/).
  • Path (e.g., repo.git in https://example.com/repo.git).
  • User name (e.g., user in https://[email protected]/repo.git)

The list above is ordered by decreasing precedence; a URL that matches a config key's path is preferred to one that matches its user name.
For example, if the URL is https://[email protected]/foo/bar a config key match of https://example.com/foo will be preferred over a config key match of https://[email protected].

All URLs are normalized before attempting any matching (the password part, if embedded in the URL, is always ignored for matching purposes) so that equivalent urls that are simply spelled differently will match properly.

Environment variable settings always override any matches.
The urls that are matched against are those given directly to Git commands.
This means any URLs +visited as a result of a redirection do not participate in matching.

Grouping repos on GitHub? [duplicate]

Problem

Here's the situation: I'm migrating a bunch of repos to github. The repos are currently organized into groups/directories like 'stack', 'websites', 'applications', etc.

There's no way (I've found) to create groups or folders on GitHub for repos, except with organizations, which seems a poor choice. But maybe not? The problem here is that some of the groups are very small, while others are large... with sub-groups, and I'd like to keep all the projects in one root bucket.

So, I'm left with maybe using a naming convention. Like: 'stack-apache', 'website-foo.com', 'application-some-project'. Or just giving up on organizing them in github and let the project pages / website handle the organization.

Re. scale, I'm looking at 20+ repos initially, with new repos added over time at an estimated rate of 2-5 /year for the next few years.

Anyone have experience with this kind of thing?

Solution and Answer

Update 2023

Github added the lists-feature (still in beta). If you star a repository you can add it to an existing list or create a new one. Still not a very intuitive way to group your own repositories but it works. list selection

starred lists

Update 2020

I'm not sure exactly when, but Github has (somewhat recently) added the concept of projects, which kind of fill the missing gap. I would argue they aren't quite the same as Bitbucket Projects but they are better suited to grouping related repo's in Github than Orgs

enter image description here


Original answer

Organisations in my opinion fit a different purpose in Github than grouping repos (although they do serve to group repos). Organisations are more about fine grained control around repo access (thats my understanding).

Bitbucket has introduced the concept of "Projects", with the following hierarchy (with a comparison to Github):

Bitbucket: Team         -> has N -> Projects -> has N -> Repos
Github:    Organisation -> has N                      -> Repos

Bitbucket still allows Repos to not be assigned to an team or project, I am guessing to support older repos that existed before the concept of a project.

To answer the question, no, not directly. There are outstanding requests with Github to add groups, but it doesn't seem likely (at this point in time).

Prefixing works as a so-so solution:

Repo name: [project]__[repo name]

Lets say you have a client "acme" with two repos:

Eg: acme__api Eg: acme__landing

Github's search is quick and inline, so doing a search for acme__ in your repo list will list all repos for the acme__ project.

Trigger a GitHub Action when another repository creates a new release

Problem

I'm trying to build a GitHub workflow that will be triggered when another repository creates a new release.

In the documentation, there is the paragraph: on.event_name.types where event_name will be release.

The question is: Is there any way to refer to the release event of another repository?

Solution and Answer

Is there any way to refer to the release event of another repository?

Fairly sure this feature does not exist.

If you have have access to the repository creating the release then you could call a webhook event to trigger an on: repository_dispatch workflow to run in another repository. repository-dispatch action can help in this case.

If you don't have access to the repository creating the release (which I assume is the case here) then this would be my suggestion. First, create the following workflow that periodically checks the release version tag of the repository you want to track. If it differs from the release version you currently have saved in your repository then the new version will be committed.

Note that you must prepare the destination file first (e.g. release-versions/swagger-ui-latest.txt) for the the modified files check to work. Further, you must use a repo scoped token instead of the default GITHUB_TOKEN. For more detail about that see Push to origin from GitHub action

name: Get latest release version
on:
  schedule:
    - cron:  '0 10 * * *'
jobs:
  get-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.REPO_SCOPED_TOKEN }}
      - name: Fetch release version
        run: |
          curl -sL https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | \
          jq -r ".tag_name" > release-versions/swagger-ui-latest.txt
      - name: Check for modified files
        id: git-check
        run: echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")
      - name: Commit latest release version
        if: steps.git-check.outputs.modified == 'true'
        run: |
          git config --global user.name 'Your Name'
          git config --global user.email '[email protected]'
          git commit -am "New release version"
          git push

Then you can create a second workflow that only runs when it sees any changes to the directory release-versions.

on:
  push:
    paths:
      - 'release-versions/*'

In this workflow you can use the saved version to fetch the assets you need and do whatever processing you need to.

Here is a similar example that raises a pull request instead of committing immediately.

Is there a Github clone in PHP that I can run on my own server? [closed]

Problem

I know there are plenty of ways to run git on my server, but I quite like the functionality of git with repo browsing - the fact that i can look at previous versions in the web interface.

Now was I able to, I'd use github, but the problem is our source control rules are very strict and we aren't allowed to put files on other servers, even if they are encrypted.

Is there a script that allows us to run a github like interface, or rather one that allows me to browse the revision history of the git project through a web interface?

I'm running a LAMP server, but would consider alternate languages like python, perl etc should nothing in php be available.

interested in both paid and open source softwares

Solution and Answer

The webapp behind Gitorious is open-source. You can have an interface exactly like it from your web server. It doesn't have all the Github bells and whistles but it has source browsing, revision history, commits, etc.

It's rails, which might not be optimal for you, but it's also free :-)

Multiple GitHub Pages and custom domains via DNS

Problem

I want to have one user page and multiple project pages hosted by GitHub Pages but available under ONE custom domain (with subdomains for each GitHub Pages repository, of course). So my goals are as follows:

As of my current understanding, GitHub Pages do only allow ONE CNAME resource record for a page (both user pages and project pages) defined in the CNAME file in the root of a Git repository. I already tried out many things (playing around with DNS records and header redirects at my domain provider EUserv, but I can only access my GitHub user pages under one URL (http://blog.florianwolters.de). I am aware that DNS changes can take up until two days.

Can somebody explain to me, how I can achieve the goals described above? I can not believe that this is not possible but I am also no expert for DNS, etc.

If the above is not possible: What is your suggested workaround? I do want to access all my GitHub pages under one domain (and the subdomains of that domain).

Resources

Solution and Answer

You can do it. Notice that all DNS CNAME entries point to the same host.

1: github.com/florianwolters/florianwolters.github.com

CNAME file content: blog.florianwolters.de

DNS CNAME: blog > florianwolters.github.com

2: github.com/florianwolters/pear/tree/gh-pages

CNAME file content: pear.florianwolters.de

DNS CNAME: pear > florianwolters.github.com

Rabu, 04 Oktober 2023

Coba coba

--- title : 'Open files always in a new tab' author : Nixpoin.com date : '2022-02-14' tags : ['visual-studio-code'] --- # Question

I am using Visual Studio Code 1.3.1 with the newly introduced tabs.

When I click on files, the first file will open in a tab. If I do not make any changes to this file, the second clicked file will open in the same tab.

How can I avoid this and make Visual Studio Code always open a new tab?

# Answer

When you [single-]click a file in the left sidebar's file browser or open it from the quick open menu (Ctrl-P, type the file name, Enter), Visual Studio Code opens it in what's called "Preview Mode", which allows you to quickly view files.

Preview Mode tabs are not kept open. As soon as you go to open another file from the sidebar, the existing Preview Mode tab (if one exists) is used. You can determine if a tab is in Preview Mode, by looking at its title in the tab bar. If the title is italic, the tab is in preview mode.

To open a file for editing (i.e. don't open in Preview Mode), double-click on the file in the sidebar, or single-click it in the sidebar then double click the title of its Preview Mode tab.

If you want to disable Preview Mode all together, you can do so by setting "workbench.editor.enablePreview": false in your settings file. You can also use the "workbench.editor.enablePreviewFromQuickOpen" option to disable it only from the quick open menu.

Before you can disable Preview Mode, you'll need to open your Settings File.

Pro Tip: You can use the Command Palette(shortcut Ctrl+Shift+P) to open your settings file, just enter "Preferences: Open User Settings"!

Once you've opened your settings file (your settings file should be located on the right), add the "workbench.editor.enablePreview" property, and set its value to false.

You can learn more about Visual Studio Code's "Preview Mode" here.
See also article How to Always Open Files in a New Tab - VSCode