在我的存储库repo1
中的分支名称environment.yml
中,我有一个文件environment.yml
。
# This is chef config file
chef:
- xxx/chef
- xxx/faster-git-clone
bam:
- xxx/asd
- V20180820_902
的内容如下:
....
# Read `environmet.yml from repo1/qa03`, and send it to Trello.
string_content = read('repo1:qa03/environment.yml') #Q: how???
send(string_content)
我想从我的python脚本中读取整个文件并将其存储在我的字符串中(以便可以将其发送到Trello卡)。
问:如何从GitHub存储库中读取具有特定分支名称的文件内容? (下面是我的伪代码)
public class Bullet extends Projectile {
private int dir;
private Bullet bullet;
public Bullet(Handler handler, float x, float y, int dir) {
super(handler, x, y, 10, 10);
this.dir = dir;
this.setWidth(6);
this.setHeight(6);
}
private void moveBullet() {
if (dir == -1) {
x -= 2;
} else {
x += 2;
}
}
public Rectangle getCollisionBounds(float xOffset, float yOffset) {
return new Rectangle((int) (x + bounds.x + xOffset), (int) (y + bounds.y + yOffset), bounds.width,
bounds.height);
}
private void checkAttacks() { //very bugged
for (Entity e : handler.getWorld().getEntityManager().getEntities()) {
// if(e.getType() != 2)
// continue;
if (e.equals(this))
continue;
if(e.getCollisionBounds(64, 64).intersects(getCollisionBounds(64, 64))) {
e.hurt(5);
System.out.println("oops");
active = false;
die();
return;
}
}
}
public void tick() {
moveBullet();
checkAttacks();
}
public void render(Graphics g) {
g.drawImage(Assets.bullet, (int) (x - handler.getGameCamera().getxOffset()),
(int) (y - handler.getGameCamera().getyOffset()), 19, 19, null);
// test
g.setColor(Color.red);
g.fillRect((int) (x + bounds.x - handler.getGameCamera().getxOffset()),
(int) (y + bounds.y - handler.getGameCamera().getyOffset()),
19, 19);
}
@Override
public void die() {
System.out.println("player-dead");
}
public Bullet getBullet() {
return bullet;
}
}
答案 0 :(得分:1)
您可以通过修改网址的以下部分来获取分支:
https://github.com/username/repositoryName/blob/branchName/path/to/file
或您的情况:
string_content = read(https://github.com/username/repo1/blob/qa03/environment.yml)
send(string_content)